例如,计算新线的出现次数?
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