PHP怎么用正则表达式匹配圆括号

PHP中文网
Release: 2023-02-28 12:56:01
Original
2927 people have browsed it

      PHP如何用正则表达式匹配圆括号
我在做CURL数据采集,要获取

 <span oncopy="setClipBoardData()"><p class="jianju">............</p><p></p></span>
Copy after login

之间的内容,
我使用正则表达式来获取。
正则表达式我写成

<span[\s]oncopy="setClipBoardData\(\)"><p[\s]class="jianju">(.*)<\/p><p><\/p><\/span>

<span[\s]oncopy="setClipBoardData()"><p[\s]class="jianju">(.*)<\/p><p><\/p><\/span>
Copy after login

都不行。应该如何写呢?

---解决方案--------------------
试试,没有问题

如果匹配多行,正则/……/s s来修饰
PHP code

$html    =<<<DOC我在做CURL数据采集,要获取 <span oncopy="setClipBoardData()">
<p class="jianju">............</p>
<p>
</p>
</span>之间的内容,DOC;preg_match(&#39;/<span[\s]oncopy="setClipBoardData\(\)">
<p[\s]class="jianju">(.*)<\/p>
<p><\/p>
<\/span>/&#39;, $html, $m);
print_r($m[1]);
Copy after login

以上就是PHP怎么用正则表达式匹配圆括号的内容,更多相关内容请关注PHP中文网(m.sbmmt.com)!

相关文章:

PHP 正则表达式常用函数使用小结

详解什么是正则表达式及其用法

php正则表达式匹配中文字符的简单代码实例

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!