views:

1915

answers:

1

I've seen a solution for not having to rework usage of the ereg function for PHP 6: http://stackoverflow.com/questions/737198/good-alternative-to-eregi-in-php

It uses if(!function_exists....

Is there a function that can be used in this way for ereg_replace?

ereg_replace("<!--.*-->","",$str);

ereg_replace("[^a-z,A-Z]", "", $str);

Thanks

+5  A: 

Use the PCRE function preg_replace instead:

preg_replace("/<!--.*-->/", "", $str);
preg_replace("/[^a-z,A-Z]/", "", $str);

POSIX ERE is (nearly) a complete subset of PCRE. So you can use (nearly) any POSIX ERE regular expression with a PREG implementation. See the Regular Expression Flavor Comparison for futher details.

Gumbo
I totally agre... preg replaced the ereg functions a long time ago
TravisO
Yes, the preg commands have been faster than the ereg commands for some time.
R. Bemrose