把这段test1<[email protected]>;test2 <[email protected]>;test3<[email protected]>;替换成
"test1" <[email protected]>;"test2" <[email protected]>;"test3" <[email protected]>;
请注意其中的空格,谢谢大家!
"test1" <[email protected]>;"test2" <[email protected]>;"test3" <[email protected]>;
请注意其中的空格,谢谢大家!
怎么匹配替换成那个格式
$str = <<<CODE
test1<[email protected]>;test2 <[email protected]>;test3<[email protected]>;
CODE;$pattern = '/(.*?)\s*<\[email protected]>;\s*/is';
$replacement = '"\1" <\[email protected]>;';
$result = preg_replace($pattern,$replacement , $str);echo $result;
?>
比如
Mr Chen<[email protected]>;姓名 PHP<[email protected]>;姓 测 试<[email protected]>