HTML and CSS Reference
In-Depth Information
EXPLANATION
This regular expression contains metacharacters (see Table 17.6). The first one is a
caret (^). The caret metacharacter matches for a string only if it is at the beginning of
the line. The period (.) is used to match for any single character, including a
whitespace. This expression contains three periods, representing any three characters.
To find a literal period or any other character that does not represent itself, the char-
acter must be preceded by a backslash to prevent interpretation.
The expression reads: Search at the beginning of the line for an a , followed by any
three single characters, followed by a c . It will match, for example, abbbc, a123c, a c,
aAx3c , and so on, but only if those patterns were found at the beginning of the line.
Table 17.6
Metacharacters and Metasymbols
Metacharacter/Met
asymbol
What It Matches
Character Class: Single Characters and Digits
.
Matches any character except newline
[a-z0-9]
Matches any single character in set
[^a-z0-9]
Matches any single character not in set
\d
Matches one digit
\D
Matches a nondigit, same as [^0-9]
\w
Matches an alphanumeric (word) character
\W
Matches a nonalphanumeric (nonword) character
Character Class: Whitespace Characters
\0
Matches a null character
\b
Matches a backspace
\f
Matches a formfeed
\n
Matches a newline
\r
Matches a return
\s
Matches whitespace character, spaces, tabs, and newlines
\S
Matches nonwhitespace character
\t
Matches a tab
 
Search WWH ::




Custom Search