另外问:
using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
string pattern = "--(.+?)--";
string replacement = "($1)";
string input = "He said--decisively--that the time--whatever time it was--had come.";
foreach (Match match in Regex.Matches(input, pattern))
{
string result = match.Result(replacement);
outputBlock.Text += result + "\n";
}
}
}
// The example displays the following output:
// (decisively)
// (whatever time it was)
这是msdn的Match.Result方法中的
只是觉得以后会碰到这种问题:如果想结果是
(decisively)
(that the time)
(whatever time it was)
怎么办??