fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. const string Str = "30-Nov-2012 30-Nov-2012 United Kingdom, 31-Oct-2012 31-Oct-2012 United Arab Emirates, 29-Oct-2012 31-Oct-2012 India";
  7. static readonly Regex r1 = new Regex("(\\d{4})\\s");
  8. static readonly Regex r2 = new Regex("(?<=\\d{4})\\s");
  9. static void TestRegex(Regex r, string s) {
  10. DateTime start = DateTime.Now;
  11. for (var i = 0 ; i != 10000 ; i++) {
  12. r.Replace(Str, s);
  13. }
  14. Console.WriteLine(DateTime.Now-start);
  15. }
  16. public static void Main()
  17. {
  18. TestRegex(r1, "$1@");
  19. TestRegex(r2, "@");
  20. TestRegex(r1, "$1@");
  21. TestRegex(r2, "@");
  22. TestRegex(r1, "$1@");
  23. TestRegex(r2, "@");
  24. TestRegex(r1, "$1@");
  25. TestRegex(r2, "@");
  26. }
  27. }
Success #stdin #stdout 4.22s 38480KB
stdin
Standard input is empty
stdout
00:00:00.4947740
00:00:00.5747460
00:00:00.4655460
00:00:00.5732990
00:00:00.4668440
00:00:00.5710920
00:00:00.4658700
00:00:00.5737650