简体   繁体   中英

How to check if a string is alphanumeric in VBScript?

Is there a function like IsNumeric() in VBScript to check if a string contains only alphanumeric (a-zA-Z0-9) characters? Or can this only be determined by regular expressions?

Use the ^ feature (not in class) of RegExps to search for characters not in (a-zA-Z0-9):

>> Set r = New RegExp
>> r.Pattern = "[^a-zA-Z0-9]"
>> For Each t In Array("aA0", "a.0")
>>     WScript.Echo t, CStr(r.Test(t))
>> Next
>>
aA0 False
a.0 True

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM