string(60) "hello, i'm 12345abcdef12345, this is my girlfriend hanmeimei"
$ cat main.php
<?php
$str = "hello, i'm abcdef, this is my girlfriend hanmeimei";
$res = preg_replace(array_pad(array(), 2, '/abcdef/'), array('12345\0', '${0}12345'), $str);
var_dump($res);
?> 正则表达式里面 ^ 匹配最开始$匹配结尾
页:
[1]