示例代码:
<?php
$html = <<< html
<p><a href="http://www.google.com" title="10">google.com</a></p>
<p><a href="http://www.cade.com" title="11">cade.com</a></p>
html;
echo preg_replace('#<p><a href\="([^>]+)" title="([^>]+)">([^>]+)</a></p>#','<p>$1 - $2</p>',$html);
?>
它工作正常,但我想知道 [^>]
是什么意思。这个我知道
+
= 1个或更多;()
= 子模式;
但是我不知道 ^>
最佳答案
表示>以外的任意字符
关于php - regex preg php 中的 [^>] 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7457973/