fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using System.Linq;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var pat = @"AbT5xY\s*(Apple|mango)";
  10. var s = "This AbT5xY\nAppleUvW is a test AbT5xY AppleUvW is a test and AbT5xrAppleUvW and another AbT5xY\nmangoUvW test";
  11. var res = Regex.Replace(s, pat, m =>
  12. m.Groups[1].Value == "Apple" ? "Fruit1" : "Fruit2");
  13. Console.WriteLine(res);
  14. }
  15. }
Success #stdin #stdout 0.03s 134784KB
stdin
Standard input is empty
stdout
This Fruit1UvW is a test Fruit1UvW is a test and AbT5xrAppleUvW and another Fruit2UvW test