与信用卡有关的正则表达式

时间:2016-04-25 16:30:54

标签: vbscript

我想验证新系列BIN范围5[1-5][0-9]{14}的主卡。目前我有现有万事达卡系列的正则表达式... {{1}}

1 个答案:

答案 0 :(得分:0)

根据 Kul-Tigin

的评论

编辑:

使用数字时,这可能会更容易:

Title = "Valid card number or not"
Do 
    CardNumber = InputBox("Please type your card number ",Title,"222100")
    If IsValidcard(CardNumber) = True Then
        MsgBox CardNumber & " The Card number is valid !",64,Title
    Else
        MsgBox CardNumber & " The Card number is not valid !",16,Title
    End if
Loop Until CardNumber = ""
'**********************************************************************
Function IsValidCard(Num)
    IsValidCard = False
    Set regEx = New RegExp
    regEx.Pattern = "^\d{6}$"
    If regEx.Test(Num) then
        x = CDbl(num)
        if x >= 222100 AND x <= 272099 Then
            IsValidCard = True
        Else
            'not in range
        End If
    Else
        'not 6 digits
    end if
End Function
'**********************************************************************