Home >Backend Development >PHP Tutorial > 网上一段简略的preg_match替换 不明
网上一段简单的preg_match替换 不明
<br /> $string = "Is is the cost of of gasoline going up up"; <br /> $pattern = "/\b([a-z]+) \\1\b/i"; <br /> if(preg_match($pattern, $string,$arr)){<br /> print_r($arr);<br /> echo preg_replace($pattern, '$1', $string);<br /> }<br />
<br /> Array<br /> (<br /> [0] => Is is<br /> [1] => Is<br /> )<br /> Is the cost of gasoline going up<br />