PROGRM
PROGRM
in multi-line pattern
* 0 or more {3} . Any character except new line (\n)
\A Start of string
+ 1 or more {3,} (a|b) a or b
$ End of string, or end of line in
? 0 or 1 {3,5} (...) Group
multi-line pattern
Add a ? to a quantifier to make it (?:...) Passive (non-capturing) group
\Z End of string
ungreedy.
[abc] Range (a or b or c)
\b Word boundary
Escape Sequences
[^abc] Not (a or b or c)
\B Not word boundary
\ Escape following character
[a-q] Lower case letter from a to q
\< Start of word
\Q Begin literal sequence
[A-Q] Upper case letter from A to Q
\> End of word
\E End literal sequence
[0-7] Digit from 0 to 7
Character Classes
"Escaping" is a way of treating
\x Group/subpattern number "
\c Control character characters which have a special
meaning in regular expressions Ranges are inclusive.
\s White space
literally, rather than as special
characters. Pattern Modifiers
\S Not white space
Common Metacharacters g Global match
\d Digit
^ [ . i * Case-insensitive
\D Not digit
Assertions
?= Lookahead assertion
?! Negative lookahead
?# Comment