Regex Match Timeout RegexMatchTimeoutException Class Constructors Properties Explicit Interface Implementations Methods Events Remarks Applies to See also Source/Reference
Regex Match Timeout
RegexMatchTimeoutException Class
The exception that is thrown when the execution time of a regular expression pattern-matching method exceeds its time-out interval.
Initializes a new instance of the RegexMatchTimeoutException class with serialized data.
RegexMatchTimeoutException(String)
Initializes a new instance of the RegexMatchTimeoutException class with the specified message string.
RegexMatchTimeoutException(String, Exception)
Initializes a new instance of the RegexMatchTimeoutException class with a specified error message and a reference to the inner exception that is the cause of this exception.
Initializes a new instance of the RegexMatchTimeoutException class with information about the regular expression pattern, the input text, and the time-out interval.
Properties
Data
Gets a collection of key/value pairs that provide additional user-defined information about the exception.
(Inherited from Exception)
HelpLink
Gets or sets a link to the help file associated with this exception.
(Inherited from Exception)
HResult
Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.
(Inherited from Exception)
InnerException
Gets the Exception instance that caused the current exception.
(Inherited from Exception)
Input
Gets the input text that the regular expression engine was processing when the time-out occurred.
MatchTimeout
Gets the time-out interval for a regular expression match.
Message
Gets a message that describes the current exception.
(Inherited from Exception)
Pattern
Gets the regular expression pattern that was used in the matching operation when the time-out occurred.
Source
Gets or sets the name of the application or the object that causes the error.
(Inherited from Exception)
StackTrace
Gets a string representation of the immediate frames on the call stack.
(Inherited from Exception)
TargetSite
Gets the method that throws the current exception.
When overridden in a derived class, sets the SerializationInfo with information about the exception.
(Inherited from Exception)
GetType()
Gets the runtime type of the current instance.
(Inherited from Exception)
MemberwiseClone()
Creates a shallow copy of the current Object.
(Inherited from Object)
ToString()
Creates and returns a string representation of the current exception.
(Inherited from Exception)
Events
SerializeObjectState
Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.
(Inherited from Exception)
Remarks
The presence of a RegexMatchTimeoutException exception generally indicates one of the following conditions:
The regular expression engine is backtracking excessively as it attempts to match the input text to the regular expression pattern.
The time-out interval has been set too low, especially given high machine load.
The way in which an exception handler handles an exception depends on the cause of the exception:
If the time-out results from excessive backtracking, your exception handler should abandon the attempt to match the input and inform the user that a time-out has occurred in the regular expression pattern-matching method. If possible, information about the regular expression pattern, which is available from the Pattern property, and the input that caused excessive backtracking, which is available from the Input property, should be logged so that the issue can be investigated and the regular expression pattern modified. Time-outs due to excessive backtracking are always reproducible.
If the time-out results from setting the time-out threshold too low, you can increase the time-out interval and retry the matching operation. The current time-out interval is available from the MatchTimeout property. When a RegexMatchTimeoutException exception is thrown, the regular expression engine maintains its state so that any future invocations return the same result, as if the exception did not occur. The recommended pattern is to wait for a brief, random time interval after the exception is thrown before calling the matching method again. This can be repeated several times. However, the number of repetitions
should be small in case the time-out is caused by excessive backtracking.