Regex help


QUOTING
\x
where x is non-alphanumeric is a literal x
\Q..\E
treat enclosed characters as literal
CHARACTERS
\a
alarm, that is, the BEL character (hex 07)
\cx
"control-x", where x is any ASCII character
\e
escape (hex 1B)
\f
formfeed (hex 0C)
\n
newline (hex 0A)
\r
carriage return (hex 0D)
\t
tab (hex 09)
\ddd
character with octal code ddd, or backreference
\xhh
character with hex code hh
CHARACTER TYPES
.
any character except newline; in s mode, any character whatsoever
\C
one byte, even in UTF-8 mode (best avoided)
\d
a decimal digit
\D
a character that is not a decimal digit
\h
a horizontal whitespace character
\H
a character that is not a horizontal whitespace character
\N
a character that is not a newline
\R
a newline sequence
\s
a whitespace character
\S
a character that is not a whitespace character
\v
a vertical whitespace character
\V
a character that is not a vertical whitespace character
\w
a "word" character
\W
a "non-word" character
CHARACTER CLASSES
[..]
positive character class
[^..]
negative character class
[x-y]
range (can be used for hex characters)
QUANTIFIERS
?
0 or 1, greedy
?+
0 or 1, possessive
??
0 or 1, lazy
*
0 or more, greedy
*+
0 or more, possessive
*?
0 or more, lazy
+
1 or more, greedy
++
1 or more, possessive
+?
1 or more, lazy
{n}
exactly n
{n,m}
at least n, no more than m, greedy
{n,m}+
at least n, no more than m, possessive
{n,m}?
at least n, no more than m, lazy
{n,}
n or more, greedy
{n,}+
n or more, possessive
{n,}?
n or more, lazy
ANCHORS AND SIMPLE ASSERTIONS
\b
word boundary
\B
not a word boundary
^
start of subject; also after internal newline in m mode
\A
start of subject
$
end of subject; also before newline at end of subject or in m mode
\Z
end of subject; also before newline at end of subject
\z
end of subject
ALTERNATION AND CAPTURING
exp|exp..
alternative
(..)
capturing group
(?<name>..)
named capturing group (Perl), or (?'name'..)
(?P<name>..)
named capturing group (Python)
(?:..)
non-capturing group
(?|..)
non-capturing group; reset group numbers for capturing groups in each alternative
(?>..)
atomic, non-capturing group
(?#..)
comment (not nestable)
OPTION SETTING
(?i)
caseless
(?J)
allow duplicate names
(?m)
multiline
(?s)
single line (dotall)
(?U)
default ungreedy (lazy)
(?x)
extended (ignore white space)
(?-..)
unset option(s)
LOOKAHEAD AND LOOKBEHIND ASSERTIONS
(?=..)
positive look ahead
(?!..)
negative look ahead
(?<=..)
positive look behind
(?<!..)
negative look behind
BACKREFERENCES
\n
reference by number (can be ambiguous)
\gn
reference by number
\g{n}
reference by number
\g{-n}
relative reference by number
\k<name>
reference by name (Perl), or \k'name'
\g{name}
reference by name (Perl)
\k{name}
reference by name (.NET)
(?P=name)
reference by name (Python)
SUBROUTINE REFERENCES (POSSIBLY RECURSIVE)
(?R)
recurse whole pattern
(?n)
call subpattern by absolute number
(?+n)
call subpattern by relative number
(?-n)
call subpattern by relative number
(?&name)
call subpattern by name (Perl)
(?P>name)
call subpattern by name (Python)
\g<name>
call subpattern by name (Oniguruma), or \g'name'
\g<n>
call subpattern by absolute number (Oniguruma), or \g'n'
\g<+n>
call subpattern by relative number (PCRE extension), or \g'+n'
\g<-n>
call subpattern by relative number (PCRE extension), or \g'-n'
CONDITIONAL PATTERNS
(?(..)..|..)
(?(condition)yes-pattern|no-pattern)
(?(n)..)
absolute reference condition
(?(+n)..)
relative reference condition
(?(-n)..)
relative reference condition
(?(<name>)..)
named reference condition (Perl), or (?('name')..)
(?(name)..)
named reference condition (PCRE)
(?(R)..)
overall recursion condition
(?(Rn)..)
specific group recursion condition
(?(R&name)..)
specific recursion condition
(?(DEFINE)..)
define subpattern for reference
(?(assert)..)
assertion condition

End of Regex help