There is no constructor like the one you use in .NET 4. Look at the documentation page ; the only options for the constructor are:
Regex ()
Regex (String)
Regex (SerializationInfo, StreamingContext)
Regex (String, RegexOptions)
EDIT
You can use Task to run the regex method and Wait
to pass a timeout. Something like this should do the job:
var regexpr = new Regex(anchorPattern[item.Key], RegexOptions.Singleline); var task = Task.Factory.StartNew(()=>regexpr.Match(foo)); var completedWithinAllotedTime = task.Wait(TimeSpan.FromMilliseconds(10));
source share