fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string str = @"Some text (* Invalid Macro Insert some text (*ValidMacroInsert*)
  9. Some text Invalid Macro Insert *) some text (*ValidMacroInsert*)";
  10. string result1 = Regex.Replace(str, @"(?m)\(\*(?=(?:(?!\(\*|\*\)).)*\(|$)", "<");
  11. string result2 = Regex.Replace(result1, @"(?<!\(\*(?:(?!\(\*|\*\)).)*)\*\)", ">");
  12. Console.WriteLine(result2);
  13. Console.ReadLine();
  14. }
  15. }
Success #stdin #stdout 0.09s 24480KB
stdin
Standard input is empty
stdout
Some text < Invalid Macro Insert some text (*ValidMacroInsert*)
Some text Invalid Macro Insert > some text (*ValidMacroInsert*)