javascript正则match使用
Code
<script language="JavaScript" type="text/JavaScript">
var testStr = "<a href=\http: onclick=\"client('argu','tgue')\">咖啡放点冰</a>";//www.leadtrade123.cn/\
var reg =/<a.*client\('(.*)','(.*)'.*>(.*)<\/a>/;
var m = testStr.match(/<a.*client\('(.*)','(.*)'.*>(.*)<\/a>/);
for (var i=0;m!=null, i < m.length; i++)
{
alert(m[i]);
}
</script>
<script language="JavaScript" type="text/JavaScript">
var testStr = "<a href=\http: onclick=\"client('argu','tgue')\">咖啡放点冰</a>";//www.leadtrade123.cn/\
var reg =/<a.*client\('(.*)','(.*)'.*>(.*)<\/a>/;
var m = testStr.match(/<a.*client\('(.*)','(.*)'.*>(.*)<\/a>/);
for (var i=0;m!=null, i < m.length; i++)
{
alert(m[i]);
}
</script>
非常好用的在线正则测试工具http://www.rubular.com/
match返回的数组从1开始,0为自身