Character Classes
|
Previous Top Next |
· Any character (.)
Matches any character except a new-line. This is the most basic match. It matches anything but new-line characters. Use this when you just need to match anything.
Matches any character except a new-line. This is the most basic match. It matches anything but new-line characters. Use this when you just need to match anything.
· Word character (\w)
Matches any character that can be used to make words.
Matches any character that can be used to make words.
· Non-word character (\W)
The opposite of \w. Matches any non-word character.
The opposite of \w. Matches any non-word character.
· White-space (\s)
Matches any white-space character. Spaces, tabs are examples of white-space.
Matches any white-space character. Spaces, tabs are examples of white-space.
· Non-white-space (\S)
Matches any non-white-space character.
Matches any non-white-space character.
· Decimal digit (\d)
Matches any decimal digit character.
Matches any decimal digit character.
· Non-decimal digit (\D)
Matches non-digit characters.
Matches non-digit characters.
· Positive Character Group ([characters])
Matches any of the specified characters. For example, [abcd] will match any of a, b, c, or d.
Matches any of the specified characters. For example, [abcd] will match any of a, b, c, or d.
· Negative Character Group ([^characters])
Matches any character that is not part of the specified list of characters. For example, [^aeiou] will match consonants, but not vowels.
Matches any character that is not part of the specified list of characters. For example, [^aeiou] will match consonants, but not vowels.
· Character Range Group ([char1-char2])
Matches any character within the range specified. For example, [0-9] matches any decimal digit (like \d). Ranges can be combined, [0-9a-fA-F] will match any hexadecimal digit, including upper and lower case letters.
Matches any character within the range specified. For example, [0-9] matches any decimal digit (like \d). Ranges can be combined, [0-9a-fA-F] will match any hexadecimal digit, including upper and lower case letters.
For detailed information on these constructs see the online reference at MSDN: