ereg_replace for PHP 5.3 +? [英] ereg_replace for PHP 5.3 +?
本文介绍了ereg_replace for PHP 5.3 +?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看到了不必重新使用PHP 5.3的ereg函数的解决方案: 在PHP中替代eregi()的好方法
I've seen a solution for not having to rework usage of the ereg function for PHP 5.3: Good alternative to eregi() in PHP
它使用if(!function_exists....
是否有可以通过这种方式用于ereg_replace
的功能?
Is there a function that can be used in this way for ereg_replace
?
ereg_replace("<!--.*-->","",$str);
ereg_replace("[^a-z,A-Z]", "", $str);
推荐答案
使用 PCRE函数 preg_replace
代替:
Use the PCRE function preg_replace
instead:
preg_replace("/<!--.*-->/", "", $str);
preg_replace("/[^a-z,A-Z]/", "", $str);
POSIX ERE(几乎)是PCRE的完整子集.因此,您可以(几乎)将任何POSIX ERE正则表达式与PREG实现一起使用.有关更多详细信息,请参见正则表达式风味比较.
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.
这篇关于ereg_replace for PHP 5.3 +?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文