Indicates whether the specified regular expression finds a match in the specified input string, using the specified matching options and time-out interval.
- input
- The string to search for a match.
- pattern
- The regular expression pattern to match.
- options
- A bitwise combination of the enumeration values that provide options for matching.
- matchTimeout
- A time-out interval, or Regex.InfiniteMatchTimeout to indicate that the method should not time out.
true if the regular expression finds a match; otherwise, false.
The erload:System.Text.RegularExpressions.Regex.IsMatch method is typically used to validate a string or to ensure that a string conforms to a particular pattern without retrieving that string for subsequent manipulation. If you want to determine whether one or more strings match a regular expression pattern and then retrieve them for subsequent manipulation, call the erload:System.Text.RegularExpressions.Regex.Match or erload:System.Text.RegularExpressions.Regex.Matches method.
The static Regex.IsMatch(string, string, RegexOptions, TimeSpan) method is equivalent to constructing a System.Text.RegularExpressions.Regex object with the regular expression pattern specified by pattern and the regular expression options specified by options and calling the Regex.IsMatch(string) instance method. This regular expression pattern is cached for rapid retrieval by the regular expression engine.
The pattern parameter consists of regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see .NET Framework Regular Expressions and Regular Expression Language Elements.
The matchTimeout parameter specifies how long a pattern matching method should try to find a match before it times out. Setting a time-out interval prevents regular expressions that rely on excessive backtracking from appearing to stop responding when they process input that contains near matches. For more information, see Best Practices for Regular Expressions in the .NET Framework and Backtracking. If no match is found in that time interval, the method throws a System.Text.RegularExpressions.RegexMatchTimeoutException exception. matchTimeout overrides any default time-out value defined for the application domain in which the method executes.