For example, [a-z] matches any lowercase letter. If the hyphen is
meant to be interpreted literally, it should be the last character before the closing
bracket, ]. Many metacharacters lose their special function when enclosed
between brackets and are interpreted literally.
[^ ] Similar to [ ], except it matches everything except the mentioned character
class. For example, [^a-c] matches all characters except a, b, and c.
$ 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 are 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 C:\Windows, you??™ll need to
refer to it as C:\\Windows.
To understand how these metacharacters work in practice, let??™s analyze one of the rewrite
rules in TShirtShop: the one that rewrites category page URLs. For rewriting category pages, we
CHAPTER 7 ?– SEARCH ENGINE OPTIMIZATION 196
have two rules??”one that handles paged categories and one that handles nonpaged categories.
Pages:
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305