日期:2014-05-17 浏览次数:20576 次
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> </head> <body> <script> var str = 'http://127.0.0.1/myo/newuser.php?mod=search&type=fastone'; var re = /(mod=)(.+?)(?=&)/i; str = str.replace(re, '$1new'); alert(str) </script> </body> </html>
------解决方案--------------------
简单点,可以这么写:
$url='http://127.0.0.1/myo/newuser.php?mod=search&type=fastone'; $url_arr=parse_url($url); parse_str($url_arr[query],$arr); $arr[mod]='new'; echo 'http://'.$url_arr[host].$url_arr[path].'?'.http_build_query($arr);