Home > Backend Development > PHP Tutorial > 求个简单的正则,该如何解决

求个简单的正则,该如何解决

WBOY
Release: 2016-06-13 13:30:36
Original
1000 people have browsed it

求个简单的正则
$str="一二三四五一二三四五...";
现在我只想替换上面的字符串中的页面显示的字符“三四”替换为“叁肆”,而超文本标签内的字符不动,替换结果如下:
$str="一二叁肆五一二三四五...";
请问怎么写这个语句?谢谢

------解决方案--------------------

PHP code
$str="<a href="xxx" title="一二三四五">一二三四五一二三四五一二三四五一二三四五\n</a><img src="xxx" alt="一二三四五">...";
echo preg_replace('/三四(?![^)/','叁肆', $str); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template