VBScript - 拒绝所有非英文字符的正则表达式

VBScript - Regular expression to reject all non-English characters

在 VBScript 代码中,我试图禁止使用非英语字符。 我创建了一个下面的函数来验证输入值:

Function Valid(ByVal value) 

        'instantiate regex object container, output boolean '
        Dim objRegEx, retVal 

        'using late binding, VBScript reference is not required '
        Set objRegEx = CreateObject("VBScript.RegExp") 

        '.pattern 
        With objRegEx 
              .Pattern = "/[^\x00-\x7F]+/" 
              .IgnoreCase = True 
              .Global = True
        End With 

        retVal = objRegEx.Test(value) 
        
        'get rid of RegEx object '
        Set objRegEx = Nothing 

        Valid = retVal 

 End Function

但是 /[^\x00-\x7F]+/ 表达式不起作用。

我需要添加什么表达式来验证字符串?

正如@Wiktor Stribiżew 在他的评论中所说, 您需要验证这样的模式 [^\x00-\x7F]

Demo Here


Option Explicit
Dim Title,MyInput
Title = "Check the validity of the input"
Do
    MyInput = InputBox("Type anything here to check its validity ",Title,"â ? è ê ½")
    If MyInput = "" Then Wscript.Quit
    If ValidationTest(MyInput) = True Then
        MsgBox DblQuote(MyInput) &" is a valid input",64,Title
    else
        MsgBox DblQuote(MyInput) &" is not a valid input",16,Title
    End If
Loop Until ValidationTest(MyInput) = True
'----------------------------------------------------
Function ValidationTest(strString)
    Dim RegularExpressionObject
    Set RegularExpressionObject = New RegExp
    With RegularExpressionObject
        .Pattern = "[^\x00-\x7F]"
        .IgnoreCase = True
        If Not .Test(strString)= True then
            ValidationTest = True
        end if
    End With
End Function
'----------------------------------------------------
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'----------------------------------------------------