练习:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>replace</title>
<script type="text/javascript">
var str0 = 'Once1a2wolf, 3always4a5wolf!';
console.log(str0.replace(/\d/g,' '));
var str1 = 'sdqqfgkkkhjppppkl';
console.log(str1.replace(/(.)\1+/g,'$').split('$'));
var str2 = '我我....我...我.要...要要...要学....学学..学.编..编编.编.程.程.程..程';
console.log(str2.replace(/\.+/g,'').replace(/(.)\1+/g,'$1'));
var str3 = '我的手机号码是17688888888,曾经用过13187654321,还用过13512345678';
console.log(str3.match(/1[3578]\d{9}/g));
</script>
</head>
<body>
</body>
</html>
效果图:
regexp
网友评论