"/music/url?q\x3dhttp://w.aaa.cn/16667639/html/download.html?id%3DS1a660980eb154960\x26resnum\x3d20\x26ct\x3ddl\x26cad\x3dsong_search\x26cd\x3d1\x26ei\x3d8YsNTuC8C4ewkAXOwfeYAg", '',
"resizable\x3d0, status\x3d0, width\x3d750, height\x3d360"
我只要:http://w.aaa.cn/16667639/html/download.html?id%3DS1a660980eb154960
这部分数据
请问这正则表达式该怎么写,谢谢!
<!doctype html>
<html>
<head>
<title>html代码</title>
<meta charset = "gb2312" />
</head>
<body>
<script>
var str = "0/music/url?q\x3dhttp://w.aaa.cn/16667639/html/download.html?id=S1a660980eb154960\x26resnum\x3d20\x26ct\x3ddl\x26cad\x3dsong_search\x26cd\x3d1\x26ei\x3d8YsNTuC8C4ewkAXOwfeYAg,resizable\x3d0, status\x3d0, width\x3d750, height\x3d360";
var reg = /(?:http[^&]*)/;
var result = str.match(reg);
alert(result);
</script>
</body>
</html>
//http:.*?\\
见二楼评论,是错了。
修改为:
(http:.*?)(?=\\)
Perl 正则表达式:m/(http:[^\]*)/
楼上的还是把‘\’匹配进去了,我觉得应该这样http:.*?(?:\\),采用分组但并非捕获
(http[^\\]+)
应该是这个
http:*[^\\]*
正解 http:*[^\\]*