• 字符统计与基本正则


    统计字符个数:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    </head>
    <body>
    <script>
    var count = 0;
    var stopposition = 0
    var item = "stop"
    var str = "start,stop,speed,start,stop,speed,start,stop,speed,start,stop,speed,"
    while( stopposition < str.length ){
    if( str.indexOf( item , stopposition) > 0 ){
    count ++
    stopposition = str.indexOf( item , stopposition)
    stopposition += item.length ;
    }else{
    stopposition += str.length
    }
    }
    console.log(str)
    console.log( '个数为', count );
    </script>
    </body>
    </html>
    正则的基本表达:
     
  • 相关阅读:
    uniapp
    vue -element admin 修改request,headers添加参数
    uniapp
    css
    uniapp
    uniapp
    vue
    vue
    vue -element 修复select下拉框在移动端需要点击两次才能选中的问题
    vue
  • 原文地址:https://www.cnblogs.com/curtain473/p/9852902.html
Copyright © 2020-2023  润新知