regular expression with ereg and eregi
Problem
You want to perform regular expression with PHP.
Solution
Again PHP implementation of regular expression is very similar to Perl.
In the simpliest form, pattern matching:
$ php -q<<EOT
<?php$str="hello world";
if(ereg("world","$str")) {
echo("got a match");
}?>
EOTgot a match
Example
Similarly eregi operates the same, just it is case insensitive.
$ php -q<<EOT
<?php$str="hello world";
if(eregi("WORLD","$str")) {
echo("got a matchn");
}?>
EOTgot a match
Reference
Technorati Tags: PHP ereg, PHP eregi, PHP Coding School

