Tuesday, 5 June 2007
Regular Expressions in PHP |
| |
|
| |
Mitchell Harper in PHPBuilder.com gives you a new tutorial on regular Expressions to manipulate strings in PHP.
For the uninitiated, a regular expression is a specially formatted pattern that can be used to find instances of one string in another. Several programming languages including Visual Basic, Perl, JavaScript and PHP support regular expressions, and the article also tries to implement some basic regular expression functionality into PHP pages.
He lists six functions that work with regular expressions in PHP. They all take a regular expression string as their first argument, and are shown below:
ereg: The most common regular expression function, ereg allows us to search a string for matches of a regular expressionereg_replace: Allows us to search a string for a regular expression and replace any occurrence of that expression with a new stringeregi: Performs exactly the same matching as ereg, but is case insensitiveeregi_replace: Performs exactly the same search-replace functionality as ereg_replace, but is case insensitive- split: Allows us to search a string for a regular expression and returns the matches as an array of strings
- spliti: Case insensitive version of the split function
|
| |
|
Read the Post
|
| |
|
|
| |
|
|
| |
|