php - regex preg php 中的 [^>] 是什么意思?

标签 php regex preg-replace

示例代码:

<?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/

相关文章:

PHP 不打印整个表格

php - 从列表中删除 'categories' 标题

php - 自动增量跳过数字?

Java - 删除引号字符串外逗号周围的空格?

php - preg_replace 如果以 a-z 开头并以 a-z 结尾则保留空格

php - 创建字符串时“unexpected T_VARIABLE”?

Python 不允许我用正则表达式做 match.group()?

java - 正则表达式删除字符串中给定的模式

php - preg_replace 超链接问题

PHP preg_replace - 不包含短语的正则表达式