Regular Expressions Special Characters

 

CHARACTER MATCHES
 
\
Toggles between literal and special characters. For example, "\w" means the special value of "\w" (see below)
^
Beginning of a string
$
End of a string
*
Zero or more times
+
One or more times
?
Zero or one time
.
Any character except newline
\b
Word boundary
\B
Non-word boundary
\d
Any digit o through 9 (same as [o-9])
\D
Any non-digit
\f
Form feed
\n
New line
\r
Carriage return
\s
Any single white space character (same as[\f\n\r\t\v])
\S
Any single non-white space character
\t
Tab
\v
Vertical Tab
\w
Any letter, number, or the underscore (same as[a-zA-Zo-9_])
\W
Any character other than a letter, number, or underscore
\xnn
The ASCII character defined by the hexadecimal number nn
\onn
The ASCII character defined by the octal number nn
\cx
The control character X
[abcde]
A character set that matches any one of the enclosed characters
[^abcde]
A complemented or negated character set; one that does not match any of the enclosed characters
[a-e]
A character set that matches any one in the range of enclosed characters
[\b]
The literal backspace character (different from \b)
{n}
Exactly n occurrences of the previous character
{n,}
At least n occurrences of the previous character
{n,m}
Between n and m occurrences of the previous character
()
A grouping, which is also stored for later use
x|y
Either x or y
   
  REGULAR EXPRESSION MODIFIERS
   
g
Search for all possible matches (globally), not just the first
i
Search without case-sensitivity