确实看不懂,看看是不是这个意思吧Regex reg = new Regex(@"(?is)(c?)(?:(?!c|结束标识).)*(结束标识)"); MatchCollection mc = reg.Matches(yourStr); foreach (Match m in mc) { richTextBox2.Text += m.Groups[1].Value + " " + m.Groups[2].Value + "\n"; } /*---------输出------------ c 结束标识 c 结束标识 c 结束标识 结束标识 */
MatchCollection mc = reg.Matches(yourStr);
foreach (Match m in mc)
{
richTextBox2.Text += m.Groups[1].Value + " " + m.Groups[2].Value + "\n";
}
/*---------输出------------
c 结束标识
c 结束标识
c 结束标识
结束标识
*/