JavaScript Editor Ajax software     Free javascripts 

Main Page

Using Table 3-2 as reference, analyze the expression
. The expression
starts with the
character, matching the beginning of the requested URL (remember, this doesn’t include
the domain name). The characters
assert that the next characters in the URL string match
those characters.
Let’s recap: the expression
will match any URL that starts with
The next characters,
, are the crux of this process. The
bit matches any character between
0 and 9 (that is, any digit), and the
that follows indicates that the pattern can repeat, so you can have an
entire number rather than just a digit. The enclosing parentheses around
indicate that the regular
expression engine should store the matching string (which will be a number) inside a variable called
(You’ll need this variable to compose the rewritten URL.)
Finally, you have
, which means that string should end in
. The
is the escaping charac-
ter, which indicates that the
should be taken as a literal dot, not as “any character” (which is the signif-
icance of the
metacharacter). The
matches the end of the string.
The second argument of
, plugs the variables that you
stored into your script URL mapping, and indicates to the web server that requests by a browser for
URLs matching that previous pattern should be delegated to that particular script with those numbers
substituted for
Metacharacter Description
( )
The parentheses are used to define a
captured expression
. The string matching the
expression between parentheses can then be read as a variable. The parentheses
can also be used to group the contents therein, as in mathematics, and operators
such as
, or
can then be applied to the resulting expression.
[ ]
Used to define a character class. For example,
will match any of the charac-
. The
character can be used to define a range of characters. For example,
matches any lowercase letter. If
is meant to be interpreted literally, it should
be the last character before
. Many metacharacters lose their special function when
enclosed between
, and are interpreted literally.
[^ ]
Similar to
[ ]
, except it matches everything except the mentioned character class.
For example,
matches all characters except
, and
Matches the end of the line. In our case, it will always match the end of the URL.
It is useful to think of it as “anchoring” the previous characters to the end of the
string, that is, asserting that they be the last part.
The backslash is used to escape the character that follows. It is used to escape
metacharacters when you need them to be taken for their literal value, rather
than their special meaning. For example,
will match a dot, rather than “any
character” (the typical meaning of the dot in a regular expression). The backslash
can also escape itself — so if you want to match
, you’ll need to refer
to it as
Chapter 3: Provocative SE-Friendly URLs
c03.qxd:c03 10:39 58

JavaScript Editor Ajax software     Free javascripts 
Bitcoin Dice Site .