标签:log mat reg car class 分享 .com png 重复
$ 表示寻找指定字符串的结尾的位置,\b 表示单词的边界例如:
var reg4=/are$/g; var reg5=/are\b/g; var str="we are thinking that that cars are"; console.log(str.match(reg4)); //["are"] console.log(str.match(reg5)); //["are", "are"]
反向引用查找重复的单词:
var reg3=/([A-Za-z]+)\s+\1\b/g; var str="we are thinking that that cars are"; console.log(str.match(reg3)); //["that that"]
标签:log mat reg car class 分享 .com png 重复
原文地址:http://www.cnblogs.com/web-fusheng/p/6883682.html