行,所以我有这个PHP脚本:的preg_replace不工作:(
<?php
$stringz = "Dan likes to eat pears and his favorite color is green!";
$patterns = array("/pears/","/green/");
$string = preg_replace($patterns, '<b>\\1</b>', $stringz);
echo "<textarea rows='30' cols='100'>$string</textarea>";
?>
,当我运行它,我得到这个: Dan likes to eat <b></b> and his favorite color is <b></b>!
的是假设有一个字。 ..但它不...
其实你总是在'\ 0`中捕捉整个事物,不管你是否有括号组。 – cambraca 2010-11-23 01:26:02
对,我的意思是他没有*明确地捕捉任何东西。 :) – Alex 2010-11-23 01:27:07