MEANING | EXAMPLE | EXPLANATION OF EXAMPLE | |
^ | 1. beginning of a line or string 2. negation, inside a character class [ ] | 1. /^ABC/ 2. /[^ABC]D/ | 1. matches ABC at the beginning of a line or string 2. matches any character before D except A or B or C |
$ | end of a line or string | /ABC$/ | matches ABC at the end of a line or string |
. | any single character | /^…$/ | matches any three letter word |
+ | one or more | /AB+/ | matches one or more B characters after A (AB, ABB, ABBB, …) |
* | zero or more | /AB*/ | matches zero or more B characters after A (A, AB, ABB, ABBB, …) |
? | zero or one | /AB?/ | matches zero or one B character after A (A, AB) |
| | alternation | /ABC|DEF/ | matches ABC or DEF |
\ | literal character | /\$50\.00/ | literally matches the string $50.00, negates the effects of the metacharacters, $ and . |
/ | boundary of regular expression | /ABC/ | matches any line with ABC in it, forward slash shows beginning and end of regular expression |
[ ] | character class | /[0-9]/ | matches any digit |
- | range | /[0-9][A-Z]/ | matches any digit followed by any capitol letter |
( ) | grouping | /(bob)*by/ | matches zero or more of the group "bob" before by (by, bobby, bobbobby, bobbobbobby, …) |