Home > Backend Development > PHP Tutorial > 被PHP的正则挫败了。

被PHP的正则挫败了。

WBOY
Release: 2016-06-13 11:28:52
Original
793 people have browsed it

被PHP的正则打败了。。。
我简单的匹配abba 这样的4个连续的数字,里面使用了子表达式和反向引用,结果没有捕获到,真不知道为什么,我哪里写错了?

<?php<br />header("Content-type:text/html;charset=utf-8");<br />$str="fdsafsdafsgfdag1223fa1551sdfassd3265";<br />$mypreg="/(\d)(\d)\2\1/";//匹配abba式的数字,即上面的1551<br />$mycon="这是数字";<br />$str=preg_replace($mypreg,$mycon,$str);<br />echo $str."<br/>";<br />
Copy after login
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