62,614
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
window.onload = function() {
var str = 'hello 123 abc 456 def 7890 hi 1344 jkl2245mno33314pqr134st123uv1234w143x1234yz';
var idx = 0;
var s = str.replace(/\d+/g, function(m) {
if(idx++ % 2 == 0) {
return m.replace(/\d/g, '#');
}
return m;
});
alert(s + '\n' + str);
}
</script>