I've been checking all over the internet but really can't find any specific solution of my problem.
How do I check if a string consists of only the declared valid characters?
I want my string to consists of only 0-9, A-Z and a-z
So the string oifrmf9RWGEWRG3oi4m3ofm3mklwef-qæw
should be invalid because of -
and æ
while the string joidsamfoiWRGWRGmoi34m3f
should be valid.
I have been using the build-in RegExp to strip the strings, but is it possible to just make it check and return a boolean false or true?
my regexp:
set pw = new regexp
pw.global = true
pw.pattern = "[^a-zA-Z0-9]"
newstring = pw.replace("iownfiwefnoi3w4mtl3.-34ø'3", "")
Thanks :)
You could do a Test which returns True or False
If( pw.Test("string") ) Then
'' Do something
End If
Try -
Dim myRegExp, FoundMatch
Set myRegExp = New RegExp
myRegExp.Pattern = "[^a-zA-Z0-9]"
FoundMatch = myRegExp.Test("iownfiwefnoi3w4mtl3.-34ø'3")
If FoundMatch
is true the RegEx engine has found a character that is not a-z or A-Z or 0-9 and your string is not valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With