Is it true that Perl functions such as preg_replace() are faster and more efficient than using string functions like str_replace() ???
Thanks
Is it true that Perl functions such as preg_replace() are faster and more efficient than using string functions like str_replace() ???
Thanks
Other way around. If you're just doing a string replacement, then use str_replace(). If you are doing a regex replacement, then do preg_replace().
http://www.php.net/manual/en/function.str-replace.php wrote:This function returns a string or an array with all occurrences of search in subject replaced with the given replace value. If you don't need fancy replacing rules (like regular expressions), you should always use this function instead of ereg_replace() or preg_replace().
But I beleive it is true that preg_replace() is often more efficient than ereg_replace():
http://www.php.net/manual/en/function.ereg-replace.php wrote:Tip: preg_replace(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to ereg_replace().