mat .cn script 正则表达式 ons ole ges rip
$ 表示寻找指定字符串的结尾的位置,\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"]
正则表达式 1
来源: http://www.bubuko.com/infodetail-2080131.html