Prev | Current Page 291 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

A regular character in
a regular expression matches the same character in the source string, and a sequence of such
characters matches the same sequence in the source string. This is similar to searching for substrings
in a string. For example, if you match ???or??? in ???favorite color???, you??™ll find two matches for it.
A regular expression can contain metacharacters, which have special properties, and it??™s
their power and flexibility that makes regular expressions so useful. For example, the question
mark (?) metacharacter specifies that the preceding character is optional. So if you want to
match ???color??? and ???colour???, your regular expression would be colou?r.
CHAPTER 7 ?–  SEARCH ENGINE OPTIMIZATION 195
As pointed out earlier, regular expressions can become extremely complex when you get
into their more subtle details. In this section, you??™ll find explanations for the regular expressions
we??™re using, and we suggest that you continue your regex training using a specialized
book or tutorial.
Table 7-2 contains the description of the most common regular expression metacharacters.
You can use this table as a reference for understanding the rewrite rules.
Table 7-2. Metacharacters Commonly Used in Regular Expressions
Metacharacter Description
^ Matches the beginning of the line. In our case, it will always match the beginning
of the URL.


Pages:
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303