I recently reviewed a pull request with a few commits focused on regular expression code changes. It's time to re-create a quick regular expression cheat sheet.
form feed character
Unicode character defined by hexadecimal number, i.e. \xFFFF
|1 or more
0 or one
0 or more
at least ‘x’ but no more that ‘y’ occurrences
digit character (0-9)
any letter or digit or underscore (_) character
characters in the range of a to x, excluding yz
characters except in the range of a to x, i.e. y and z
|if the first character, indicates that the match starts at beginning of string
Match must continue to end of string
- The first character ^ indicates that the next match (19|20) starts at beginning of string.
- We either need a 19 or a 20 at the beginning of the string.
- Next we have two digit character (0-9).
- Next we have a range of valid characters, in this case minus, slash, space and dot.
- Next we have two possible combinations of digits.
5.1 Either we have a 0, followed by a digit in the range of 1-9, i.e. 01 to 09.
5.2 Or we have a 1, followed by a zero, one or two, i.e. 10, 11 or 12.
- The last character $ indicates that the next match must continue to end of string.
- Next we have three possible combinations of digits.
7.1 Either we have a 0, followed by a digit in the range of 1-9, i.e. 01 to 09.
7.2 Or we have a 1 or a 2, followed by a digit in the range of 0-9, i.e. 10 to 29.
7.3 Or we have a three, followed by a zero or a one, i.e. 30 - 31.
If you need more examples, go to regularexpressions.info.