本文介绍了警告:preg_match()[function.preg-match]:未知修饰符'('的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个HTML标记:
I have this HTML tags :
<div class="title">Copy me if you can</div>
所以我想使用preg_match拍摄请复制我"我正在使用此preg模式:
so I wanna use preg_match to take just "Copy me if you can"I'm using this preg pattern :
$preg = "<div class=\"title\">(.+?)</div>";
所以我写了这段代码
$match = preg_match($preg,$content);
浏览器输出:
Warning: preg_match() [function.preg-match]: Unknown modifier '('
什么
推荐答案
您忘记了定界符
$preg = '~<div class="title">(.+?)</div>~';
模式中的第一个字母始终定义要使用的定界符.在您的情况下,其为<
,因此结尾的定界符为>
.之后的所有内容均用作特殊修饰符,可更改特定行为. (
不是有效的修饰符.那就是错误消息想要告诉您的内容:)
The first letter in the pattern always defines the delimiter to use. In your case its <
, so the ending delimiter is >
. Everything after that is used as special modifier, that changes specific behaviours. (
is not a valid modifier. Thats what the error message wanted to tell you :)
这篇关于警告:preg_match()[function.preg-match]:未知修饰符'('的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!