fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6.  
  7. namespace dotnetRegex
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var text = $"{Environment.NewLine}a{Environment.NewLine}b";
  14.  
  15. var patN = @"^.*$";
  16. var reN = new Regex(patN);
  17. var msN = reN.Matches(text);
  18. Console.WriteLine($"Begin and end specified: {msN.Count}");
  19. Console.WriteLine();
  20.  
  21. var patB = @"^.*";
  22. var reB = new Regex(patB);
  23. var msB = reB.Matches(text);
  24. foreach (var mB in msB)
  25. Console.WriteLine($"Begin specified only : {string.Join(" ", mB.ToString().Select(c => (int)c))}");
  26. Console.WriteLine();
  27.  
  28. var patE = @".*$";
  29. var reE = new Regex(patE);
  30. var msE = reE.Matches(text);
  31. foreach (var mE in msE)
  32. Console.WriteLine($"End specified only : {string.Join(" ", mE.ToString().Select(c => (int)c))}");
  33. }
  34. }
  35. }
  36.  
Success #stdin #stdout 0.08s 20592KB
stdin
Standard input is empty
stdout
Begin and end specified: 0

Begin specified only   : 

End specified only     : 98
End specified only     :