/.../
: Start and end regex delimiters|
: Alternation()
: Grouping
^
: Start of string or start of line in multi-line mode$
: End of string or end of line in multi-line mode\Z
: End of string\b
: Word boundary\B
: Not word boundary\<
: Start of word\>
: End of word
\s
: Whitespace\S
: Not whitespace\w
: Word\W
: Not word\d
: Digit\D
: Not digit\x
: Hexadecimal digit\O
: Octal digit
\n
: Newline\r
: Carriage return\t
: Tab\v
: Vertical tab\f
: Form feed\xxx
: Octal character xxx\xhh
: Hex character hh
.
: Any character except newline (\n)(a|b)
: a or b(...)
: Group[abc]
: a, b, or c[^abc]
: Not a, b or c[a-z]
: Letters from a to z[A-Z]
: Uppercase letters from A to Z[0-9]
: Digits from 0 to 9
Note: Ranges are inclusive.
*
: 0 or more+
: 1 or more?
: 0 or 1{3}
: Exactly 3{3,}
: 3 or more{3,5}
: 3, 4 or 5
Note: Quantifiers are greedy - they match as many times as possible.
\
:Escape following character. Used to escape any of the following metacharacters:{}[]()^$.|*+?\.
\1
: 1st group\2
: 2nd group\n
: nth group
[:upper:]
: Uppercase letters[:lower:]
: Lowercase letters[:alpha:]
: All letters[:alnum:]
: Digits and letters[:digit:]
: Digits[:xdigit:]
: Hexadecimal digits[:punct:]
: Punctuation[:blank:]
: Space and tab[:space:]
: Blank characters[:cntrl:]
: Control characters[:graph:]
: Printed characters[:print:]
: Printed characters and spaces[:word:]
: Digits, letters and underscore
Note: Class abbreviations must appear inside character classes. E.g.
[[:alnum:]]
is equivalent to[a-zA-Z0-9]
and[[:digit:]cse]
is equivalent to[0-9cse]
.
/.../g
: Global match (don't stop at first match within the line)/.../i
: Case-insensitive