You are on page 1of 3

Use To match character Use To define

\p{ctgry} In that Unicode category or block (exp) Indexed group


\P{ctgry} Not in that Unicode category or (?<name>exp) Named group
block (?<name1- Balancing group
\w Word character name2>exp)
\W Non-word character (?:exp) Noncapturing group
Use To match any character \d Decimal digit (?=exp) Zero-width positive
[set] In that set \D Not a decimal digit lookahead
[^set] Not in that set \s White-space character (?!exp) Zero-width negative
[az] In the a-z range \S Non-white-space char lookahead
[^az] Not in the a-z range (?<=exp) Zero-width positive
lookbehind
. Any except \n (new line)
\char Escaped special character (?<!exp) Zero-width negative
Greedy Lazy Matches lookbehind
* *? 0 or more times (?>exp) Non-backtracking (greedy)
+ +? 1 or more times
Use To match Unicode ? ?? 0 or 1 time
\t Horizontal tab \u0009 {n} {n}? Exactly n times
\v Vertical tab \u000B Option Effect on match
{n,} {n,}? At least n times
\b Backspace \u0008 i Case-insensitive
{n,m} {n,m}? From n to m times
\e Escape \u001B m Multiline mode
\r Carriage return \u000D n Explicit (named)
\f Form feed \u000C s Single-line mode
\n New line \u000A Use To specify position x Ignore white space
\a Bell (alarm) \u0007 ^ At start of string or line
\c char ASCII control \A At start of string Use To
character \z At end of string (?imnsx- Set or disable the specified
\Z At end (or before \n at end) of string imnsx) options
$ At end (or before \n at end) of string (?imnsx- Set or disable the specified
Use To match character with or line imnsx:exp) options within the
\octal 2-3 digit octal character code \G Where previous match ended expression
\x hex 2-digit hex character code \b On word boundary June 2014
\u hex 4-digit hex character code \B Not on word boundary 2014 Microsoft. All rights reserved.
Class: System.Text.RegularExpressions.Regex
Use To match Category Description
\n Indexed group Lu Letter, uppercase Pattern matching with Regex objects
\k<name> Named group LI Letter, lowercase To initialize with Use constructor
Lt Letter, title case
Lm Letter, modifier
Regular exp Regex(String)
Lo Letter, other + options Regex(String, RegexOptions)
Use To match L Letter, all + time-out Regex(String, RegexOptions,
a |b Either a or b Mn Mark, nonspacing combining TimeSpan)
Mc Mark, spacing combining
(?(exp) yes if exp is matched
Me Mark, enclosing combining Pattern matching with static methods
yes | no) no if exp isn't matched M Mark, all diacritic Use an overload of a method below to supply the
(?(name) yes if name is matched Nd Number, decimal digit regular expression and the text you want to search.
yes | no) no if name isn't matched Nl Number, letterlike
No Number, other Finding and replacing matched patterns
N Number, all To Use method
Pc Punctuation, connector
Use To substitute Validate match Regex.IsMatch
Pd Punctuation, dash
$n Substring matched by group Ps Punctuation, opening mark Retrieve single Regex.Match (first)
number n Pe Punctuation, closing mark match Match.NextMatch (next)
${name} Substring matched by group Pi Punctuation, initial quote mark Retrieve all Regex.Matches
name Pf Puntuation, final quote mark matches
Po Punctuation, other
$$ Literal $ character Replace match Regex.Replace
P Punctuation, all
$& Copy of whole match Sm Symbol, math
Divide text Regex.Split
$` Text before the match Sc Symbol, currency Handle char Regex.Escape
$' Text after the match Sk Symbol, modifier escapes Regex.Unescape
$+ Last captured group So Symbol, other
S Symbol, all Getting info about regular expression patterns
$_ Entire input string
Zs Separator, space To get Use Regex API
Zl Separator, line Group names GetGroupNames
Zp Separator, paragraph
GetGroupNameFromNumber
Use To Z Separator, all
Cc Control code Group numbers GetGroupNumbers
(?# comment) Add inline comment GetGroupNumberFromName
Cf Format control character
# Add x-mode comment Cs Surrogate code point Expression ToString
For detailed information and examples, see Co Private-use character
Options Options
http://aka.ms/regex Cn Unassigned
C Control characters, all Time-out MatchTimeOut
To test your regular expressions, see Cache size CacheSize
http://regexlib.com/RETester.aspx For named character set blocks (e.g., Cyrillic), search
for "supported named blocks" in the MSDN Library. Direction RightToLeft

You might also like