Prev | Current Page 290 | Next

Emilian Balanescu and Cristian Darie

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

For example, regular expressions
can be used to extract or validate e-mail addresses, find valid dates in strings, remove
duplicate lines of text, find the number of times a word or a letter appears in a phrase, find or
validate IP addresses, and so on.
In the previous exercise, you used mod_rewrite rules, using regular expressions, to match
incoming keyword-rich URLs and obtain their rewritten, dynamic versions. A bit later in this
chapter, we??™ll use a regular expression that prepares a string for inclusion in the URL, by replacing
unsupported characters with dashes and eliminating duplicate separation characters.
Regular expressions are supported by many languages and tools, including the PHP language
and the mod_rewrite Apache module, and the implementations are similar. A regular
expression that works in PHP will work in Java or C# without modifications most of the time.
When you want to do an operation based on regular expressions, you usually must provide at
least three key elements:
??? The source string that needs to be parsed or manipulated
??? The regular expression to be applied on the source string
??? The kind of operation to be performed, which can be either obtaining the matching
substrings or replacing them with something else
Regular expressions use a special syntax based on regular characters, which are interpreted
literally, and metacharacters, which have special matching properties.


Pages:
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
Dyskusja Nr6 ciekawe zdania imprezy integracyjne dla firm Cd Poker gdyz