Useful Escape Sequences

Contents | Up | Prev | Next

# 7.9. Useful Escape Sequences

Perl has several escape sequences which are specific to regular expressions. Here is a list of some of the more useful ones:

- `\w` - matches a word character, equivalent to `[A-Za-z_]`. The corresponding sequence - `\W` matches a non-word character.
- `\s` - matches a whitespace character, usually space and tab. `\S` matches a non-whitespace character.
- `\d` - matches a digit. Equivalent to `[0-9]`. `\D` matches a non-digit.
- `\b` - matches a word boundary. This sequence in fact has a zero width but it is nevertheless highly useful. `\B` matches something that is not a word boundary.

Contents | Up | Prev | Next