language: C# (mono-2.8)
date: 202 days 2 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using System.Text.RegularExpressions;
 
public class Test
{
    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";
    static readonly Regex r1 = new Regex("(\\d{4})\\s");
        static readonly Regex r2 = new Regex("(?<=\\d{4})\\s");
    static void TestRegex(Regex r, string s) {
        DateTime start = DateTime.Now;
        for (var i = 0 ; i != 10000 ; i++) {
            r.Replace(Str, s);
        }
        Console.WriteLine(DateTime.Now-start);
    }
    public static void Main()
        {
                TestRegex(r1, "$1@");
        TestRegex(r2, "@");
        TestRegex(r1, "$1@");
        TestRegex(r2, "@");
        TestRegex(r1, "$1@");
        TestRegex(r2, "@");
        TestRegex(r1, "$1@");
        TestRegex(r2, "@");
        }
}