日期:2014-05-17 浏览次数:20390 次
比如: 链接A : http://user.qzone.qq.com/[color=#FF0000]1340477530[/color]#!app=2&pos=[color=#FF0000]1300412602[/color] 链接B :http://b.qzone.qq.com/cgi-bin/blognew/blog_output_data?uin=[color=#FF0000]xxxxx[/color]&blogid=[color=#FF0000]yyyyyyy[/color]&numperpage=1000&property=GoRE
$str1 = "http://user.qzone.qq.com/1340477530#!app=2&pos=1300412602"; $str2 = "http://b.qzone.qq.com/cgi-bin/blognew/blog_output_data?uin=1111&blogid=2222&numperpage=1000&"; preg_match('/([\d]+).*pos=([\d]+)$/', $str1, $match); if (isset($match[1]) && isset($match[2])) { $pa=array('/uin=[\d]+/','/blogid=[\d]+/'); $re=array('uin='.$match[1],'blogid='.$match[2]); $str2=preg_replace($pa,$re,$str2); echo $str2; }