zoukankan      html  css  js  c++  java
  • js常用的正则表达操作

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script>
                  var past=/helloword/gi;
                  var str='helloword my HelloWord baby';
                  console.log(past.test(str));//返回true or false
    
                  console.log(past.exec(/aa/));//返回匹配到的字符串及其位置 匹配不到返回null
                  console.log(past.exec(str));//返回匹配到的字符串及其位置 匹配不到返回null
                  console.log(str.match(past));//返回匹配到的字符串        匹配不到返回null
                  console.log(str.match(/aa/));//返回匹配到的字符串        匹配不到返回null
                  console.log(str.search(/1/));//返回匹配到的字符串位置     匹配不到返回-1
                  console.log(str.replace(past,"你好"));//字符串替换
                  console.log(str.split(' '));//字符串拆分成数组
                  console.log(str.split(/s+/));//s+匹配空字符串
        </script>
    </head>
    <body>
    
    </body>
    </html>
  • 相关阅读:
    Django ListView实现分页
    redis-pipeline
    MRO
    进程状态
    ORM基本操作回顾
    协程回顾
    线程的回顾
    multiprocessing- 基于进程的并行性
    Fix Curl client hung issue
    Curl request 'Expect: 100-Continue' Issues and Risks
  • 原文地址:https://www.cnblogs.com/wujindong/p/6265575.html
Copyright © 2011-2022 走看看