Chiyuki regular expression syntax reference

千雪正規表現の構文のリファレンス

Single characters:
.any character, not including newline (\n)
[xyz]character class
[^xyz]negated character class
Composites:
xyx followed by y
x|yx or y (prefer x)
Repetitions:
x*zero or more x, prefer more
x+one or more x, prefer more
x?zero or one x, prefer one
x{n,m}n or n+1 or ... or m x, prefer more
x{n,}n or more x, prefer more
x{n}exactly n x
x*?zero or more x, prefer fewer
x+?one or more x, prefer fewer
x??zero or one x, prefer zero
x{n,m}?n or n+1 or ... or m x, prefer fewer
x{n,}?n or more x, prefer fewer
x{n}?exactly n x
Possessive repetitions:
x*+zero or more x, possessive
x++one or more x, possessive
x?+zero or one x, possessive
x{n,m}+n or ... or m x, possessive
x{n,}+n or more x, possessive
x{n}+exactly n x, possessive
Grouping:
(x)numbered capturing group
(?P<name>re)named & numbered capturing group
(?<name>re)named & numbered capturing group
(?'name're)named & numbered capturing group
(?:x)non-capturing group
(?|x|y|z)branch numbering reset
(?>re)possessive match of re
Flags:
Insensitivecase-insensitive (default false)
Multilinemulti-line mode: ^ and $ match begin/end line in addition to begin/end text (default false)
AnchoredAnchor to start of pattern (default false)
Exportsave numbered capturing groups, get capturing group by calling member function getCaptured (default false)
Empty strings:
^at beginning of text or line (Multiline=true)
$at end of text (like \z not \Z) or line (Multiline=true)
\bat word boundary (\w on one side and \W, \A, or \z on the other)
\Bnot a word boundary
(?=x)before text matching x
(?!re)before text not matching x
(?<=re)after text matching x
(?<!re)after text not matching x
Escape sequences:
\fform feed (≡ \014)
\thorizontal tab (≡ \011)
\nnewline (≡ \012)
\rcarriage return (≡ \015)
\vvertical tab character (≡ \013)
\123octal character code (up to three digits)
\x7Fhex character code (exactly two digits)
\u00A9hex character code (exactly four digits)
\U000000A9hex character code (exactly eight digits)
\1backreference
\g1backreference
\g{1}backreference
\g{+1}backreference
\g{-1}backreference
\k<name>named backreference
\k'name'named backreference
\cKcontrol char ^K (use \001 etc)
Character class elements:
[x]single character
[A-Z]character range (inclusive)
[^A-Z]character range (non-inclusive)
Named character classes as character class elements:
[\d]digits (≡ \d)
[^\d]not digits (≡ \D)
[\D]not digits (≡ \D)
[^\D]not not digits (≡ \d)
Perl character classes:
\ddigits (≡ [0-9])
\Dnot digits (≡ [^0-9])
\swhitespace (≡ [\t\n\f\r ])
\Snot whitespace (≡ [^\t\n\f\r ])
\wword characters (≡ [0-9A-Za-z_])
\Wnot word characters (≡ [^0-9A-Za-z_])
Magic:
(?n)recursive call to regexp capturing group n
(?+n)recursive call to relative group +n
(?-n)recursive call to relative group -n
(?R)recursive call to entire regexp (≡ (?0))
(?&name)recursive call to named group
(?P=name)named backreference
(?P>name)recursive call to named group
(?(cond)true|false)conditional branch
(?(cond)true)conditional branch
Chiyuki | Home
Hingchung Chu | Trilines 2015