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实现类似PHP中preg_match_all()功能的方法,通过正则表达式匹配并提取HTML代码中的特定字符串,展示了如何在JavaScript中进行字符串匹配和解析。
804

被折叠的 条评论
为什么被折叠?



