HTML and CSS Reference
Several backslash sequences match particular types of characters. For example, \d matches any digit: 0, 1, 2,
3, 4, 5, 6, 7, 8, or 9. \D matches any character that is not a digit. (Capitalization often reverses the sense of a
pattern.) Other such classes include the following.
A whitespace character: space, tab, carriage return, or line feed. This is very important in HTML because
usually in HTML these four characters are interchangeable. \s does not match the non-breaking space.
Any nonwhitespace character.
Any word character—that is, any letter or digit but not punctuation marks or spaces. However, the
underscore, _, is considered to be a word character in most regular-expression dialects. Whether non-
ASCII characters are considered individually or excluded as a group varies according to dialect.
Any nonword character.
Any digit from 0 to 9. In some dialects, this also matches non-ASCII digits such as (the Japanese 1) and
(the Arabic 1) as well.
Any character except 0 to 9; in some dialects, any character that is not a digit.