javascript 正则匹配 提取全部 preg_match_all matchAll方法

时间:2014-07-31 20:58:27   收藏:0   阅读:1714

javascript 提取所有的的方法,javascript中没有matchAll这个方法。

用while来实现类似 PHP 中的preg_match_all() :(by default7#zbphp.com)

<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>

<select name="AgentIdP" id="AgentIdP" onchange="selectNull('AgentIdI333');selectNull('GameId333');"></select>
<script type="text/javascript">
var html = document.getElementById('AgentIdP').getAttribute('onchange');
var exp = /selectNull\([\'"]{1}([\w-]+)[\'"]{1}\)/ig;
var result ;
while( (result = exp.exec(html))!= null){
	console.log(result);
}
console.log(html);
</script>
</body>
</html>



javascript 正则匹配 提取全部 preg_match_all matchAll方法,布布扣,bubuko.com

原文:http://blog.csdn.net/default7/article/details/38321203

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!