(10101101)173/C#2009. 2. 6. 22:27
string insertStr = "CountCounCoun tCount";

System.Text.RegularExpressions.Regex cntStr = new System.Text.RegularExpressions.Regex("Count");
returnStr = int.Parse(cntStr.Matches(insertStr, 0).Count.ToString());

이 구문을 사용하기 위헤서는 using문에 다음과 같이 선언해 줘야 사용이 가능 합니다.

using System.Text.RegularExpressions;

세어야 할 글자 "Count"를 insertStr에서 세게 됩니다. "Coun과 Coun t"는 "Count"와 다르기 때문에 최종적으로 나오는 값은 2가 됩니다.
Posted by Special Alex