Home > Backend Development > PHP Tutorial > preg_replace 不支持元字符"b"该如何解决

preg_replace 不支持元字符"b"该如何解决

WBOY
Release: 2016-06-13 13:09:58
Original
906 people have browsed it

preg_replace 不支持元字符"\b"???
我想匹配一个单词,例如hi,想用\b标出开始与结束。但是用这个函数无法执行。后来在网上查了说是用/作为定界符,但是匹配的时候还是将所有的都匹配了。无法做到匹配单独的hi这个单词?请高手赐教一下

------解决方案--------------------
/\bhi\b/ 也行的, 你试试
------解决方案--------------------

PHP code
$a ='fhia hi fefefhi hiasdf hi';
$b = '/\bhi\b/';
$c = 'jj';
echo preg_replace($b,$c,$a); <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