Click or drag to resize
Regex Class
Represents an immutable regular expression.
Inheritance Hierarchy
SystemObject
  System.Text.RegularExpressionsRegex

Namespace: System.Text.RegularExpressions
Assembly: CSharpXamlForHtml5.System.dll (in CSharpXamlForHtml5.System.dll.dll) Version: 1.0.0.0
Syntax
C#
public class Regex

The Regex type exposes the following members.

Constructors
  NameDescription
Protected methodRegex
Initializes a new instance of the System.Text.RegularExpressions.Regex class.
Public methodRegex(String)
Initializes a new instance of the System.Text.RegularExpressions.Regex class for the specified regular expression.
Public methodRegex(String, RegexOptions)
Initializes a new instance of the System.Text.RegularExpressions.Regex class for the specified regular expression, with options that modify the pattern.
Top
Methods
  NameDescription
Public methodEquals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodStatic memberEscape
Escapes a minimal set of characters (\, *, +, ?, |, {, [, (,), ^, $,., #, and white space) by replacing them with their escape codes. This instructs the regular expression engine to interpret these characters literally rather than as metacharacters.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsMatch(String)
Indicates whether the regular expression specified in the System.Text.RegularExpressions.Regex constructor finds a match in a specified input string.
Public methodIsMatch(String, Int32)
Indicates whether the regular expression specified in the System.Text.RegularExpressions.Regex constructor finds a match in the specified input string, beginning at the specified starting position in the string.
Public methodStatic memberIsMatch(String, String)
Indicates whether the specified regular expression finds a match in the specified input string.
Public methodStatic memberIsMatch(String, String, RegexOptions)
Indicates whether the specified regular expression finds a match in the specified input string, using the specified matching options.
Public methodMatch(String)
Searches the specified input string for the first occurrence of the regular expression specified in the System.Text.RegularExpressions.Regex constructor.
Public methodMatch(String, Int32)
Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position in the string.
Public methodStatic memberMatch(String, String)
Searches the specified input string for the first occurrence of the specified regular expression.
Public methodMatch(String, Int32, Int32)
Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position and searching only the specified number of characters.
Public methodStatic memberMatch(String, String, RegexOptions)
Searches the input string for the first occurrence of the specified regular expression, using the specified matching options.
Public methodMatches(String)
Searches the specified input string for all occurrences of a regular expression.
Public methodMatches(String, Int32)
Searches the specified input string for all occurrences of a regular expression, beginning at the specified starting position in the string.
Public methodStatic memberMatches(String, String)
Searches the specified input string for all occurrences of a specified regular expression.
Public methodStatic memberMatches(String, String, RegexOptions)
Searches the specified input string for all occurrences of a specified regular expression, using the specified matching options.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodReplace(String, String)
In a specified input string, replaces all strings that match a regular expression pattern with a specified replacement string.
Public methodStatic memberReplace(String, String, String)
In a specified input string, replaces all strings that match a specified regular expression with a specified replacement string.
Public methodStatic memberReplace(String, String, String, RegexOptions)
In a specified input string, replaces all strings that match a specified regular expression with a specified replacement string. Specified options modify the matching operation.
Public methodToString
Returns the regular expression pattern that was passed into the Regex constructor.
(Overrides ObjectToString.)
Public methodStatic memberUnescape
Converts any escaped characters in the input string.
Top
Fields
  NameDescription
Public fieldStatic memberInfiniteMatchTimeout
Specifies that a pattern-matching operation should not time out.
Top
Properties
  NameDescription
Public propertyOptions
Gets the options that were passed into the System.Text.RegularExpressions.Regex constructor.
Public propertyRightToLeft
Gets a value that indicates whether the regular expression searches from right to left.
Top
Examples
Here is an example of a use of Regex that checks if an email address is valid:
C#
if (Regex.IsMatch(TextBoxEmailAddress.Text, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"))
    MessageBox.Show(TextBoxEmailAddress.Text + " is a valid email address.");
else
    MessageBox.Show(TextBoxEmailAddress.Text + " is NOT a valid email address.");
See Also