Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| // <Snippet3> | |
| using System; | |
| using System.Diagnostics; | |
| using System.Text.RegularExpressions; | |
| public class Example | |
| { | |
| public static void Main() | |
| { | |
| string pattern = "^(a+)+$"; | |
| string[] inputs = { "aaaaaa", "aaaaa!" }; | |
| Regex rgx = new Regex(pattern); | |
| Stopwatch sw; | |
| foreach (string input in inputs) { | |
| sw = Stopwatch.StartNew(); | |
| Match match = rgx.Match(input); | |
| sw.Stop(); | |
| if (match.Success) | |
| Console.WriteLine("Matched {0} in {1}", match.Value, sw.Elapsed); | |
| else | |
| Console.WriteLine("No match found in {0}", sw.Elapsed); | |
| } | |
| } | |
| } | |
| // </Snippet3> |