将 ereg_replace 更改为 preg_replace
我该如何更改
$output = ereg_replace("<script.*</script>", "", $output);
为preg?
I tried $output = preg_replace("/<script.*</script>/", "", $output);
谢谢
编辑:抱歉,格式混乱
How would I change
$output = ereg_replace("<script.*</script>", "", $output);
to preg?
I tried $output = preg_replace("/<script.*</script>/", "", $output);
Thanks
EDIT: Sorry, messed up formatting
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用
/
作为分隔符,则必须转义模式中每次出现的/
,或者其被识别为分隔符本身,并且后面的所有内容都会被转义。用作修饰符(这可能会失败)。或者您可以让自己的生活变得轻松,只需选择不同的分隔符即可。我更喜欢
~
,因为它出现的模式相当罕见更新:请参阅描述的注释,这里发生了什么
If you use
/
as the delimiter, you must escape every occurence of/
within the pattern, or its recocnized as delimiter itself and everthing following will be used as modifiers (which will probably fail).or you make your life easy and just choose a different delimiter. I prefer
~
, because it occurs in patterns quite infrequentUpdate: See comments for the description, what happens here