preg_replace:未知修饰符
假设 $body 等于
something
that
does
not
interest
me
<!-- start -->
some
html
code
<!-- end -->
something
that
does
not
interest
me
如果我使用
$body=preg_replace("(.*)<!-- start -->(.*)<!-- end -->(.*)","$2",$body);
我获得:
警告:preg_replace() [function.preg-replace]:未知修饰符“<”
我该如何纠正?
Let's assume that $body is equal to
something
that
does
not
interest
me
<!-- start -->
some
html
code
<!-- end -->
something
that
does
not
interest
me
If I use
$body=preg_replace("(.*)<!-- start -->(.*)<!-- end -->(.*)","$2",$body);
I obtain:
Warning: preg_replace() [function.preg-replace]: Unknown modifier '<'
How have I to correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
preg
模式需要一对字符来分隔模式本身。在这里,您的模式包含在第一对括号中,其他所有内容都在外面。试试这个:
这只是关于语法,并且不能保证看起来可疑的模式本身。
假设您的示例中的文本:
A
preg
pattern needs a pair of characters which delimit the pattern itself. Here your pattern is enclosed in the first pair of parentheses and everything else is outside.Try this:
This is just about the syntax, and there is no guarantee on the pattern itself which looks suspicious.
Assuming the text in your example:
试试这个:
Try this: