zoukankan      html  css  js  c++  java
  • 字符的统计

    <!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>
    正则的基本表达:
  • 相关阅读:
    [Redis]在.NET平台下的具体应用
    [Redis]在Windows下的下载及安装
    【重读MSDN之ADO.NET】ADO.NET连接
    贪心
    树状数组
    并查集
    模拟
    kruskal
    树链剖分
    匈牙利算法
  • 原文地址:https://www.cnblogs.com/xichen25/p/10060136.html
Copyright © 2011-2022 走看看