Regex class now support time out setting for regular expression finding match if its take long time in .net 4.5. We are able to set timeout setting with regex class in .Net 4.5 like
Regex regexpr = new Regex("[a-z ]{10}", RegexOptions.Singleline, TimeSpan.FromMilliseconds(1));
You can also specify Regex.InfiniteMatchTimeout for timeout does not occur. The value of Regex.InfiniteMatchTimeout is -1 internally so we can specify Timespan.Frommilliseconds(-1) for regular expression never timeout. This is default behavior of our regex class
Published under: Microsoft .NET Tips · · · ·