zoukankan      html  css  js  c++  java
  • 正则表达式1

     $ 表示寻找指定字符串的结尾的位置, 表示单词的边界例如:

     var reg4=/are$/g;
       var reg5=/are/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/g;
       var str="we are thinking that      that cars      are";
       console.log(str.match(reg3)); //["that      that"]

     

  • 相关阅读:
    SEO搜索引擎
    SEO
    编程的智慧
    ES6编程规范
    面试题集
    motto
    motto
    JS
    motto
    Linux
  • 原文地址:https://www.cnblogs.com/web-fusheng/p/6883682.html
Copyright © 2011-2022 走看看