function replace_w($content='')
{
$reg = '/[\"]+(.*)[\"]+/iU';
$content = preg_replace_callback($reg, function($match){
$content = '【'.$match[1].'】';
return $content;
}, $content);
return $content;
}
$str = '"ABC"
"GRY"
"XXX"
';
print_r(nl2br($str));
echo '---------<br/>';
$str = replace_w($str);
print_r(nl2br($str));
结果是这样的:
"ABC"
"GRY"
"XXX"
---------
【ABC】
【GRY】
"XXX"
怎么匹配可以让 "
和 "
同时生效