The eregi_replace function operates identically to ereg_replace with the
exception that letters are matched with no regard for upper or lower case.
array split(string pattern, string text, integer limit)
The split function returns an array of substrings from the text argument. The
pattern argument will be used as a field delimiter. The optional limit argument sets
the maximum number of elements to return. There is no case-insensitive version of split.
Compare this function to explode, which uses a simple string to delimit substrings.
Regular expression processing is slower than straight string matching, so use explode
when you can.
<?
$paragraph = "This is a short paragraph. Each ";
$paragraph .= "sentence will be extracted by ";
$paragraph .= "the split function. As a ";
$paragraph .= "result, you will be amazed!";
$sentence = split("[.!\?]", $paragraph);
for($index = 0; $index < count($sentence);
$index++)
{
print("$index. $sentence[$index]
\n");
}
?>
Perl-Compatible Regular Expressions
Andrei Zmievski added support to PHP for Perl-compatible regular expressions.
Expressions are surrounded by delimiters, which are usually / or | characters, but can be
any printable character other than a number, letter, or backslash. After the second
delimiter, you may place one or more modifiers. These are letters that change the way the
regular expression is interpreted.
For the most part, the functions in this section comply with the way regular expressions
work in Perl 5. There are a few very specific differences. They are narrow enough that
you probably won't run into them, and they may not make much sense without explaining
regular expressions in detail. If you're curious, read the excellent notes in the PHP
manual available online <http://www.php.net/manual/html/ref. pcre.html>.
array preg_grep(string pattern, array data)