php正则表达式匹配一段中文,中间有换行,空白,应该怎么写?

WBOY
Release: 2016-06-06 20:28:27
Original
1110 people have browsed it

1、举个例子:

<code><div class="con">
    <p>
        小学生手册:<br>
        1、好好学习;<br>
        2、天天向上;<br>
    </p>
</div>
</code>
Copy after login
Copy after login

要把中间p标签中的内容抓出来,正则表达式应该怎么写?

回复内容:

1、举个例子:

<code><div class="con">
    <p>
        小学生手册:<br>
        1、好好学习;<br>
        2、天天向上;<br>
    </p>
</div>
</code>
Copy after login
Copy after login

要把中间p标签中的内容抓出来,正则表达式应该怎么写?

<code>$tmp = '<div class="con">
    <p>
        小学生手册:<br>
        1、好好学习;<br>
        2、天天向上;<br>
    </p>
</div>';

preg_match('/<p>(.*?)/s', $tmp, $ret);

echo $ret[1];</p></code>
Copy after login

请参看 PCRE_MULTILINE 模式修饰符 m
http://php.net/manual/zh/reference.pcre.pattern.modifiers.php

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template