Regular Expressions

NiKeFiDO

Diamond Member
May 21, 2004
3,901
1
76
Hi all -

I am trying to use Regular Expressions to validate that the user is entering an acceptable password upon creation. I am coding in Visual Basic in VS2005.

I'd like to have at least one lower case, one upper case and one digit.

I found a guide from VS2003 using this string:

^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,20}$

However, while this seems to work in in the video guide, it does not work when I am doing it in VS2005 (It gives an error no matter what I do).

Is anyone familiar with using Regular Expressions and it's syntax? MSDN's pages are pretty vague (who woulda thought?)

Here is my code:
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Regex.IsMatch(Me.PasswordTextBox.Text, "^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,20}$")

Maybe you can try swapping the arguments, i.e.

Regex.IsMatch("^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,20}$",Me.PasswordTextBox.Text)

I thought the VB6 "Like" operator had some requirement that the regular expression be in one argument.
 

NiKeFiDO

Diamond Member
May 21, 2004
3,901
1
76
Originally posted by: xtknight
Regex.IsMatch(Me.PasswordTextBox.Text, "^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,20}$")

Maybe you can try swapping the arguments, i.e.

Regex.IsMatch("^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,20}$",Me.PasswordTextBox.Text)

I thought the VB6 "Like" operator had some requirement that the regular expression be in one argument.

Interestingly, switching the two arguments did not cause VS to yell at me. However, I still get the exact same behavior (the errorprovider still gives me an error)....

Possibly it is something other than the regular expression string :(