Regex.MatchTimeout Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the time-out interval of the current instance.
public:
property TimeSpan MatchTimeout { TimeSpan get(); };
public TimeSpan MatchTimeout { get; }
member this.MatchTimeout : TimeSpan
Public ReadOnly Property MatchTimeout As TimeSpan
Property Value
The maximum time interval that can elapse in a pattern-matching operation before a RegexMatchTimeoutException is thrown, or InfiniteMatchTimeout if time-outs are disabled.
Remarks
The MatchTimeout property defines the approximate maximum time interval for a Regex instance to execute a single matching operation before the operation times out. The regular expression engine throws a RegexMatchTimeoutException exception during its next timing check after the time-out interval has elapsed. This prevents the regular expression engine from processing input strings that require excessive backtracking. For more information, see Backtracking and Best Practices for Regular Expressions.
This property is read-only. You can set its value explicitly for an individual Regex object by calling the Regex(String, RegexOptions, TimeSpan) constructor; and you can set its value for all Regex matching operations in an application domain by calling the SetData(String, Object) method and providing a TimeSpan value for the "REGEX_DEFAULT_MATCH_TIMEOUT" property.
If you do not explicitly set a time-out interval, the default value InfiniteMatchTimeout is used, and matching operations do not time out.