日期:2014-05-17 浏览次数:20437 次
<?php
header("Content-type:text/html;charset=utf-8");
$str="fdsafsdafsgfdag1223fa1551sdfassd3265";
$mypreg="/(\d)(\d)\2\1/";//匹配abba式的数字,即上面的1551
$mycon="这是数字";
$str=preg_replace($mypreg,$mycon,$str);
echo $str."<br/>";
$a = "/(\d)(\d)\2\1/";bool(false) string(12) "/(\d)(\d)/" string(14) "/(\d)(\d)\2\1/"
$b = '/(\d)(\d)\2\1/';
var_dump($a == $b);
var_dump($a, $b);
$a = "/(\d)(\d)\\2\\1/";bool(true) string(14) "/(\d)(\d)\2\1/" string(14) "/(\d)(\d)\2\1/"
$b = '/(\d)(\d)\2\1/';
var_dump($a == $b);
var_dump($a, $b);
$str="fasdgasgdfgfduuuuuu1221uuuuufasdfsdfsdaf4444";
$mypreg='/(\d)\1{3}/i';
$mycon="这是数字";
echo $str."<br/>";
$str=preg_replace($mypreg,$mycon,$str);
echo $str."<br/>";