用正则关键词替换时 不替换A标记中的内容
Release: 2016-06-13 13:36:11
Original
935 people have browsed it
求助用正则关键词替换时 不替换A标记中的内容?
HTML code
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<a href="#">测试</a>俺吧拉萨看来大家阿司法局刷卡机放<a href="#">测试一下</a>得开疯测试狂的萨克龙卷风看到<a href="#">测试</a>测试放得开松垮垮发静测试看思渡口开测试始 倒萨
Copy after login
替换掉 测试 二字为一个链接如:
替换 但 已经在A标记中的 测试 不进行替换
弄了好久都无法实现。求思路
------解决方案--------------------
能实现
1.(?)(?:(?!
]+>).)+(]+>|$)
匹配得到以外的部分
2.将这结果中的 测试 替换为你要的内容
如果不支持(?(^|)(?:(?!]+>).)+(]+>|$)
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
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31