4 Pattern Matching
4 Pattern Matching
4 Pattern Matching
Javascript
Pattern
matching
Pattern matching
Metacharacters are
characters that have
special meanings in some
contexts in patterns.
The following are the
pattern metacharacters:
\|()[]{}^$*+?.
Metacharacters can
themselves be matched
by being immediately
preceded by a backslash.
A period matches any
character except newline.
Preferred Character
Classes
ANCHORS
PATTERN MODIFIERS
search(pattern)
replace(pattern,string)
match(pattern)
split(parameter)
search(pattern)
str.replace(/rab/g, "tim");
match(pattern)
match(pattern)
var matches =
str.match(/[ab]/g);
split(parameter)