| Symbol | What it matches |
| . | Matches any single character except newline |
| [a-z0-9] | Matches any single charecter of set |
| [^a-z0-9] | Matches any single charecter NOT in set |
| \d | Matches a digit (a number 0-9) |
| \D | Matches a non-digit (anything but 0-9) |
| \w | Matches an alphanumeric charecter (a-zA-Z0-9 and _) |
| \W | Matches a non-alphanumeric charecter |
| \s | Matches a whitespace character (space, tab, newline) |
| \S | Matches a non-whitespace character |
| \n | Matches a newline |
| \r | Matches a return |
| \t | Matches a tab |
| \f | Matches a formfeed |
| \b | Matches a backspace (inside [] only) |
| \0 | Matches a null character |
| \b | Matches a word boundary (outside [] only) |
| \B | Matches a non-word boundary |
| ^ | Anchors match to the beginning of a line or string |
| $ | Anchors match to the end of a line or string |
| x? | Matches 0 or 1 x's, where x is any of the above |
| x* | Matches 0 or more x's |
| x+ | Matches 1 or more x's |
| x{m,n} | Matches at least m x's, but no more than n |
| (pat1|pat2) | Matches either pat1 or pat2 |
| (pat) | Stores a pattern for backreferencing via $1, $2 through $9 |
|
|
Note: All other characters match themselves, except for these special characters: + ? / * ^ $ @ () [] | \ To match one of these, you
have to use a backslash (e.g. "\@" matches "@").
|
m//, s//, and qr// operators all except the following modifiers after their delimiter:
| Modifier | Meaning |
| /i | Ignore alphabetic case distinctions (case insensitive) |
| /s | Let . match newline and ignore deprecated $* variable |
| /m | Let ^ and $ match next to embedded \n |
| /x | Ignore (most) whitespace and permit comments in pattern |
| /o | Compile pattern once only |
s// specific modifiers:
| Modifier | Meaning |
| /g | Replace globally, that is, all occurrences |
| /e | Evaluate the right side as an expression |
|