onGroups and Ranges Quantifiers Anchors . ^ Start of string * 0 or more \A Start of string + 1 or more $ End of string ? 0 or 1 (a|b) a or b \Z End of string {3} Exactly 3 (...) Group \b Word boundary {3,} 3 or more (?:...) Passive Group \B Not word boundary {3,5} 3, 4 or 5 [abc] Range (a or b or c) \< Start of word [^abc] Not a or b or c \> End of word [a-q] Letter between a and q [A-Q] Upper case letter Character Classes \c White space \S Not white space \d Digit \D Word \W Not word \x Hexadecimal digit \O Octal digit Ungreedy version of "x" Not digit \w between A and Q "x" below represents a quantifier Control character \s new line (\n) Quantifier Modifiers x? Escape Character \ Any character except Escape Character [0-7] Digit between 0 and 7 \n nth group/subpattern Note: Ranges are inclusive. Pattern Modifiers g Case-insensitive m Metacharacters (must be escaped) Global match i Multiple lines ^ [:lower:] All letters [:alnum:] Digits and letters [:digit:] Digits * x Allow comments and \ + | ? < > white space in pattern e Evaluate replacement U Ungreedy pattern Lower case letters [:alpha:] Treat string as single line { ) Upper case letters s ( [:upper:] . $ POSIX [ [:xdigit:] [:punct:] Hexadecimal digits Punctuation [:blank:] Space and