例如,計算新線的出現次數?
string="help/nsomething/ncrayons"
輸出:
String word count is: 3
這是我有什麼,但在程序循環,雖然該方法幾次,它看起來像我只得到最後創建的字符串。這裏的代碼塊:
Regex regx = new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.IgnoreCase);
MatchCollection matches = regx.Matches(output);
//int counte = 0;
foreach (Match match in matches)
{
//counte = counte + 1;
links = links + match.Value + '\n';
if (links != null)
{
string myString = links;
string[] words = Regex.Split(myString, @"\n");
word_count.Text = words.Length.ToString();
}
}
它是\n
換行。
。我們可以假設你的意思是\ n對於換行符,但如果你能清楚這一點會更好嗎? – rtpHarry 2011-04-22 22:15:07