zoukankan      html  css  js  c++  java
  • 微软的IsNumeric函数有错误

    随便建立一个asp文件,然后输出Response.Write(IsNumeric("2d3"))你看看就知道了,对此,自己写了一个函数来替代之,代码如下,用法与IsNumeric完全相同,只不过是函数名字不同罢了(没办法,这个函数不允许重写,所以只好重命名一个函数):

    //如果要轉載本文請注明出處,免的出現版權紛爭,我不喜歡看到那種轉載了我的作品卻不注明出處的人 Seven{See7di#Gmail.com}

    <%
    Function IsNum(Values)
    IsNum = False
    If IsNull(Values) Or Len(Values)=0 Then
       IsNum = False
       Exit Function
    End If
    Dim Regex
    Set Regex = new Regexp
       regex.Global = False
       regex.IgnoreCase = False
       regex.Pattern="^[-]{0,1}[0-9]{0,}[.]{0,1}[0-9]{0,}$"
       IsNum=regex.Test(Values)
    Set Regex=Nothing
    End Function

    Dim a(11),iNum
    a(0) = "-.1"
    a(1) = "-1.1"
    a(2) = "-0.1"
    a(3) = "0.1"
    a(4) = ".1"
    a(5) = "111.132234345345354"
    a(6) = "+.1"
    a(7) = "111"
    a(8) = "asfd.1"
    a(9) = "-1"
    a(10) = "188.188.188"
    a(11) = "18a8.1"
    Response.Write "<table border=1>"
    For i = 0 to 11
        Response.Write "<tr><td>" & a(i) & "</td><td>" & IsNum(a(i)) & "</td>"
    Next
    Response.Write "</table>"
    %>


  • 相关阅读:
    生成树
    如何自定义百度网盘分享密码
    斯特林数入门
    各种反演难题训练集合
    LOJ[6247]九个太阳
    min25筛入门
    2020 Petrozavodsk Winter Camp, Jagiellonian U Contest-A-Bags of Candies
    ICPC WF 2018 C Conquer the World 征服世界
    dsu on tree
    生成函数入门级内容
  • 原文地址:https://www.cnblogs.com/see7di/p/2239930.html
Copyright © 2011-2022 走看看