我的世界有好多美妙的东西[嘻嘻],真的感谢上帝的恩赐[哈哈],人生如梦
如何通过正则表达式把"[嘻嘻]","[哈哈]"找出来呢
using System.Text.RegularExpressions; private void button1_Click(object sender, EventArgs e) { string str = " 我的世界有好多美妙的东西[嘻嘻],真的感谢上帝的恩赐[哈哈],人生如梦"; string partten = @"\[\w+\]"; MatchCollection mc=Regex.Matches(str, partten,RegexOptions.IgnoreCase); MessageBox.Show(mc.Count.ToString()); for (int i = 0; i < mc.Count; i++) { string temp= mc[i].Value; MessageBox.Show(temp); } }