开发者

Replace eregi_replace with preg_replace

How do I convert this functio开发者_Python百科n with this parameters

eregi_replace('<[^>]*>', '', $stringToDisplay)

to preg_replace?


The PCRE regular expressions require delimiters that separate the pattern from optional modifiers (in this case i to reflect a case insensitive match):

preg_replace('/<[^>]*>/i', '', $stringToDisplay)

But since there are not letters that need to be interpreted without case, you can omit the i modifier.

And if you happen to try parsing HTML or a similar markup language with regular expressions, consider using a proper parser.


Try

preg_replace('/\<[^>]*\>/i', '', $stringToDisplay)

More details - http://php.net/manual/en/function.preg-replace.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜