Datasheet

The ^ character at the start of the pattern means that only strings that begin with the word Flickr will
be matched. In the three sample strings, only one matches:
Flickr Mashups
Similarly, this regexp
/Flickr$/
only matches the string that ends with Flickr:
I like Flickr
The period (.) will match any character, so the following pattern will match any string that has an F and
an
r separated by four characters:
/F....r/
That means it will match all three of the Flickr strings, and will also match these two:
Farmer Giles has a herd of cows
Fly around the world
The asterisk (*) is a modifier that means “zero or more occurrences” of the preceding character. So, the
regexp
/che*se/
will match
cheese
cheeeeeeeese
chse
Similarly, the plus (+) and question mark (?) characters are modifiers that mean one or more occurrences
and exactly zero or one occurrences, respectively.
You can use square brackets to enclose a set of alternatives, so the regexp
/br[eo]ad/
will match both bread and broad.
You can use
\d to match a numeric digit (0–9) and \w to represent a “word” character (a letter or digit, or
the underscore character), so the regexp
/\d\d\d\d-\d\d-\d\d/
can be used to match dates in the format yyyy-mm-dd.
18
Part I: Building a New Internet
05_097748 ch01.qxp 12/14/06 5:53 PM Page 18