Export (0) Print
Expand All

Regex.MatchTimeout Property

.NET Framework 4.5

Gets the time-out interval of the current instance.

Namespace:  System.Text.RegularExpressions
Assembly:  System (in System.dll)

public TimeSpan MatchTimeout { get; }

Property Value

Type: System.TimeSpan
The maximum time interval that can elapse in a pattern-matching operation before a RegexMatchTimeoutException is thrown, or Regex.InfiniteMatchTimeout if time-outs are disabled.

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 in the .NET Framework.

This property is read-only. You can set its value explicitly for an individual Regex object by calling the Regex.Regex(String, RegexOptions, TimeSpan) constructor; and you can set its value for all Regex matching operations in an application domain by calling the AppDomain.SetData method and providing a value for the "REGEX_DEFAULT_MATCH_TIMEOUT" property. If you do not explicitly set a time-out interval, the default value Regex.InfiniteMatchTimeout is used, and matching operations do not time out.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft