Regex.Match Method (String, String, RegexOptions)
Searches the input string for the first occurrence of the regular expression supplied in a pattern parameter with matching options supplied in an options parameter.
Assembly: System (in System.dll)
- Type: System.String
The string to search for a match.
- Type: System.String
The regular expression pattern to match.
- Type: System.Text.RegularExpressions.RegexOptions
A bitwise combination of the enumeration values.
Return ValueType: System.Text.RegularExpressions.Match
An object that contains information about the match.
The static Match methods are equivalent to constructing a Regex object with the specified pattern and calling the instance method Match.
The pattern parameter consists of various regular expression language elements that symbolically describe the string to match. For more information about regular expressions, see Regular Expression Language Elements in the .NET Framework documentation.
If you want to restrict a match so it does not scan, anchor the regular expression with a \G (at the left for a left-to-right pattern, or at the right for a right-to-left pattern). This restricts the match so it must start exactly at startpos.
When a Regex is left-to-right (the default), the match and the scan proceed rightward, starting at the character at startat. When a Regex is right-to-left (constructed with the RightToLeft option enabled), the match and scan are in the opposite direction and begin with the character at startat -1.
You can determine whether the regular expression pattern has been found in the input string by checking the value of the returned Match object's Success property. If a match is successful, the returned Match object's Value property contains the substring from input that matches the regular expression pattern. If no match is found, its value is String.Empty.
This method returns the first substring found in input that matches the regular expression pattern. You can retrieve subsequent matches by repeatedly calling the returned Match object's NextMatch method. You can also retrieve all matches in a single method call by calling the Regex.Matches(String, String, RegexOptions) method.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.