zoukankan      html  css  js  c++  java
  • JavaScript计算字符串中包含几个给定字符

    原文发布时间为:2009-05-04 —— 来源于本人的百度文章 [由搬家工具导入]

    下面以 逗号 为例子:

    <html>
    <head>
    <title>
    JavaScript计算字符串中包含几个给定字符
    </title>
    </head>
    <body>
    <script language="javascript">
    function calculate()
    {
    //正则[^,]字符,是你需要统计的字符
    document.all.result.value=document.all.uInput.value.replace(/[^,]/g, '').length;
    }
    </script>
    请输入<input name="uInput" type="text" value="12,13,14,">
    <input type="button" value="计算" onclick="calculate()"/>
    结果为<input name="result" type="text">
    </body>
    </html>

  • 相关阅读:
    Friends ZOJ
    2^x mod n = 1 HDU
    Paint the Grid Reloaded ZOJ
    Treap 模板
    bzoj进度条
    。。。
    bzoj
    。。。
    bzoj
    题解continue
  • 原文地址:https://www.cnblogs.com/handboy/p/7153277.html
Copyright © 2011-2022 走看看