php 正则表达式报错,高手请进。
$str = preg_replace("/(?]*)(茶叶)(?!\"|)/sui", '茶叶', $str, 5);
报错如下:
Warning: preg_replace() [function.preg-replace]: Compilation failed: lookbehind assertion is not fixed length at offset 10 in D:\AppServ\www\Template\test.php on line 28
------解决方案--------------------
试试
$<a style="color:#f60; text-decoration:underline;" title="html" href="https://www.php.cn/zt/15763.html" target="_blank">html</a> =
<span title="中国好茶叶">中国茶叶</span>
这儿是中国茶叶大观的链接。
这儿是<a href="%E5%8E%9F%E6%9C%89%E7%9A%84%E9%93%BE%E6%8E%A5.html">茶叶</a>的现有链接
html;
echo preg_replace('#(?=[^>]*(?=)|$))茶叶#','<a href="%E6%96%B0%E5%8A%A0%E7%9A%84%E9%93%BE%E6%8E%A5.html">\0</a>',$html);
} <div class="clear"></div>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号