Home >Backend Development >PHP Tutorial >PHP正则反向摘引求解

PHP正则反向摘引求解

WBOY
WBOYOriginal
2016-06-13 11:28:58747browse

PHP正则反向引用求解?
使用php反向捕获又不知道怎么回事了。

把下面字符串里面的4个连续的数外面的符号去掉。

fsdfsdafasfasdfsdf2365}>

,还请分析下我写的哪里有问题?

<?php<br />header("Content-type:text/html;charset=utf-8");<br />$str="fsdfsdafasfasdfsdf<{2365}>";<br />$mypreg="/<{(\d\d\d\d)}>/";//()里面表示4个连续的数,使用括号表示我捕获这个子表达式,一会引用<br />$mycon="\1"; //这个是替换内容,我反向引用上面的4个数字2365,用这4个数字替换上面有外符号的整块<{2365}><br />echo $str;<br />echo "<br/>";<br />$str=preg_replace($mypreg,$mycon,$str);<br />echo $str;<br />


结果是能够捕获到 这个东东,但是反向引用怎么都没有内容,应该是反向引用错了,没有引用到内容。求指点。

Statement:
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