This documentation is archived and is not being maintained.

Regex Class

Represents an immutable regular expression.

For a list of all members of this type, see Regex Members.


[Visual Basic]
Public Class Regex
   Implements ISerializable
public class Regex : ISerializable
public __gc class Regex : public ISerializable
class Regex implements ISerializable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


The Regex class contains several static methods that allow you to use a regular expression without explicitly creating a Regex object. Using a static method is equivalent to constructing a Regex object, using it once and then destroying it.

The Regex class is immutable (read-only) and is inherently thread safe. Regex objects can be created on any thread and shared between threads. For more information, see Thread Safety.


Namespace: System.Text.RegularExpressions

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System (in System.dll)

See Also

Regex Members | System.Text.RegularExpressions Namespace | .NET Framework Regular Expressions | Regular Expression Language Elements