84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
你好世界 <img title="你好世界" alt="你好世界">这段文字,怎么通过php的正则表达式函数 替换成你<a>好世</a>界<img title="你好世界" alt="你好世界">要求就是关键词在标签属性内的不加a标签。在标签以外的都加上。
<img title="你好世界" alt="你好世界">
<a>好世</a>界<img title="你好世界" alt="你好世界">
认证高级PHP讲师
$subject = '<img title="你好世界" alt="你好世界">你好世界<img title="你好世界" alt="你好世界">'; $pattern = "/(好世)(?![^\'\"><]*[\'\"])/"; $result = preg_replace ( $pattern, "<a>$1</a>", $subject ); echo $result;
认证高级PHP讲师