Regular Expression Character Classes

Introduction

The table  specifies some character classes that can be used with regular expressions. Please do not confuse a character class with a C# class declaration. A character class is simply an escape sequence that represents a group of characters that might appear in a string.

Character class

Matches

\d

any digit

\w

any word character

\s

any whitespace

\D

any non-digit

\W

any non-word character

\S

any non-whitespace

A word character is any alphanumeric character or underscore. A white space character is a space, a tab, a carriage return, a newline or a form feed. A digit is any numeric character. Regular expressions are not limited to the character classes . Regular expressions can use other notations to search for complex patterns in strings.