1.var str = "我的手机号码是17688888888,曾经用过13187654321,还用过13512345678"
result = str.match(/1[3-9]\d{9}/g);
alert(result);
176888888.jpg2.var str = '我我....我...我.要...要要...要学....学学..学.编..编编.编.程.程.程..程';
str = str.replace(/./g,'');//我我我我要要要要学学学学编编编编程程程程
result = str.match(/(.)\1+/g);//我我我我,要要要要,学学学学,编编编编,程程程程
var L=''
for(i in result){
L+=result[i][0]
}
alert(L)
3.var str = "sdqqfgkkkhjppppkl"
s=str.replace(/(.)\1+/g," ")//sd fg hj kl
result = s.split(" ")
alert(result);
4.var str = "Once1a2wolf,3always4a5wolf!"
var result = str.replace(/\d/g," ")
alert(result)
网友评论