Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 匹配第一个<;p>;它不是以regexp中的图像开始的_Php_Regex_Preg Replace - Fatal编程技术网

Php 匹配第一个<;p>;它不是以regexp中的图像开始的

Php 匹配第一个<;p>;它不是以regexp中的图像开始的,php,regex,preg-replace,Php,Regex,Preg Replace,在PHP中,我试图匹配第一个段落标记,该标记后面不紧跟 到目前为止,我已经成功地将一个类添加到第一个段落标记中,但它不会跳过,直到找到一个不立即包含图像的段落标记: <p>Text</p> preg_replace(“//”,“”,$text,1); 想法?如果没有意义,就道歉。/(?)?! <p><strong>Strong text</strong></p> <p><img src="" /&g

在PHP中,我试图匹配第一个段落标记,该标记后面不紧跟

到目前为止,我已经成功地将一个类添加到第一个段落标记中,但它不会跳过,直到找到一个不立即包含图像的段落标记:

<p>Text</p>
preg_replace(“//”,“

”,$text,1);

想法?如果没有意义,就道歉。

/(?)?!
<p><strong>Strong text</strong></p>
<p><img src="" /></p>
preg_replace('/<p>/','<p class="first">', $text, 1);
/<p>(?!<img)/<p class="first">/