日期:2014-05-17 浏览次数:20745 次
string pattern = @"(?i)(\d+[^::]+?)[::]\s*?(\d+)(盒|瓶)";//定义匹配规则 string tempStr = File.ReadAllText(@"C:\Users\M\Desktop\Test.txt", Encoding.GetEncoding("GB2312"));//读取文档 StringBuilder sb = new StringBuilder(); foreach (Match m in Regex.Matches(tempStr, pattern)) { sb.Append(m.Value);//找到匹配项,并整合 } this.richTextBox1.Text = sb.ToString();