fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string pattern = @"(?is)\bEmail:\s*([^@]+@[^.]+\.[a-z0-9]{2,6}(?:\.[a-z0-9]{2,6})?)$";
  9. string input = @"OrderId:009
  10. Email:Ardi1234@yahoo.com
  11. ProductId:X206
  12.  
  13. OrderId:009
  14. Email: Ardi1234@yahoo.co.uk
  15. ProductId:X206
  16.  
  17. OrderId:009
  18. EMAIL: Ardi1234@yahoo.co.uk
  19. ProductId:X206";
  20. RegexOptions options = RegexOptions.Multiline;
  21.  
  22. foreach (Match m in Regex.Matches(input, pattern, options))
  23. {
  24. Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
  25. }
  26. }
  27. }
Success #stdin #stdout 0.06s 21236KB
stdin
Standard input is empty
stdout
'Email:Ardi1234@yahoo.com' found at index 24.
'Email: Ardi1234@yahoo.co.uk' found at index 117.
'EMAIL: Ardi1234@yahoo.co.uk' found at index 217.