| Token | Meaning | Token | Meaning | |
|---|---|---|---|---|
| / | Start and end of Ruby regular expression | \ / | Literal / | |
| ^ | Start of line | \^ | Literal ^ | |
| $ | End of line | \$ | Literal $ | |
| \A | Start of input string | A | Literal A | |
| \Z | End of input string | Z | Literal Z | |
| \b | Word boundary | b | Literal b | |
| \B | Non-word boundary | B | Literal B | |
| [a-z] | Any lower case letter | \[ | Literal [ | |
| [A-Z] | Any upper case letter | \] | Literal ] | |
| [^a-z] | Any non-lower case letter | - | Literal - | |
| [^A-Z] | Any non-upper case letter | \\ | Literal \ | |
| \d | Any digit; same as [0-9] | d | Literal d | |
| \D | Any non-digit; same as [^0-9] | D | Literal D | |
| \w | Any word character; same as [A-Za-z0-9] | w | Literal w | |
| \W | Any non-word character; same as [^A-Za-z0-9] | W | Literal W | |
| \s | Any whitespace character; same as [ \n\r\f\t\v] | s | Literal s | |
| \S | Any non-whitespace character; same as [^ \n\r\f\t\v] | S | Literal S | |
| ( ) | Grouping | \( \) | Literal ( ) | |
| | | Or | \| | Literal | | |
| . | Any character | \. | Literal . | |
| ? | 0 or 1 occurrences | \? | Literal ? | |
| * | 0 or more occurrences | \* | Literal * | |
| + | 1 or more occurrences | \+ | Literal + | |
| {n} | Exactly n occurrences | \{ | Literal { | |
| {n,m} | Between n and m occurrences, inclusive | \} | Literal } |