|
Using Regular Expressions
Understanding the Three Regular Expression Command Sets
What is a regular expression?
A regular expression uses a set of pre-defined symbols to describe a string
What use is a regular expression in designing a website?
Regular expressions can be used to validate information which comes from an "untrustworthy" source. Regular expressions can also be used to extract information out of web documents and to perform "clean up"
What is validation?
Validation is the process of verifying that information is in the expected format and "follows the rules"
What are the families of regular expression commands?
ereg*, mb_ereg*, and preg* All three rely on different PHP extensions
Why is the preg* family recommended for use?
The ereg* family has been "deprecated" (obsolete -- scheduled to be removed from the PHP language). mb_ereg is based on the ereg* family, and is therefore also obsolete, but it supports multi-byte strings. The preg* family is being actively developed and supported.
Can you use the preg* family for multi-byte strings?
When you add the "u" modifier at the end of the pattern (another lesson), the preg* family supports UTF-8 encoded multi-byte strings
What is a multi-byte string?
A multi-byte string occupies more than one byte when stored, and is used to represent any international character set including Chinese, Thai, Arabic, etc.
Is there a performance disadvantage when using regular expressions?
Yes! If you only need to know character types, consider using the ctype* family instead. If the string you are searching for does not change, use "strpos()" or "stripos()"
|
|