Mega Code Archive

 
Categories / C# / Development Class
 

Returns the expansion of the specified replacement pattern

using System; using System.Text.RegularExpressions; public class Example {    public static void Main()    {       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);          Console.WriteLine(result);       }    } }