August 5, 2005
LOL Thanks for:
#1 the reminder that it is backslashes and not forwardslashes.
#2 that the period needs a backslash behind it
Now, I think there is something that we all missed.... (with the
assumption that blank strings are okay), is to append the ^ to the front
AND and $ to the back... which means that the WHOLE string must conform to
the pattern and not just one part (which can be just 1 char). This is a
common security slip up that even I made a mistake in my original post.
Also, I always like to list out things like A-Za-z so that I never
accidentally forget that a char set contains something I didn't want like
a char return, etc. So:
if regex.ismatch(inputstring,"^[A-Za-z\d\._]{0,}$") = false then
msgbox("Invalid")
else
msgbox("Valid")
end if
This will work and I have tested it. Hope this helps and people are free
to comment!
--
Joseph Bittman
Microsoft Certified Solution Developer
Web Site:
http://71.39.42.23
Static IP
said:
| "[A-Za-z/d-.]{0,}" - it doesn't work!
no, it doesn't.
"[^\.\d\w_]"
nor does that.
this *does* based on the op's requirements:
"^[a-z\d_]*$"
the requirements were:
a-z
A-Z
0-9
_
why are periods in both you guy's exps? also, "[^\.\d\w_]" only says the
string has to *start* with a *single correct character* but can be
followed
by *any* character.