By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,971 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,971 IT Pros & Developers. It's quick & easy.

vb.net regex question

P: n/a
Not sure where to ask this. Please suggest another newsgroup if this
isn't the best place for this question.

I'm new to both vb.net and regex. I need a regular expression that will
validate what people are entering as their new password.

Must be between 6 and 10 characters
Must be alphanumeric only
Can not be the word "password" in any case ie "pAsSworD" should also be
denied.

the following works just fine for catching the lenght and the
alphanumeric requirement. My question really is how to match only if
"password" isn't their password.

"^([a-zA-Z0-9]{6,10})$"

Seems like it'd be easy but, like I said I'm new to regex.

Thanks!

Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
hi...

if you'd like to know about regular expressions check this link, a nice
tutor on regex.

http://www.codeproject.com/dotnet/RegexTutorial.asp.

else if u'd directly want the answer to your question use this link and
download the regex generator and validation tool.

http://www.codeproject.com/dotnet/expresso.asp

hope this helps,
Kannan.V

"en*****@yahoo.com" wrote:
Not sure where to ask this. Please suggest another newsgroup if this
isn't the best place for this question.

I'm new to both vb.net and regex. I need a regular expression that will
validate what people are entering as their new password.

Must be between 6 and 10 characters
Must be alphanumeric only
Can not be the word "password" in any case ie "pAsSworD" should also be
denied.

the following works just fine for catching the lenght and the
alphanumeric requirement. My question really is how to match only if
"password" isn't their password.

"^([a-zA-Z0-9]{6,10})$"

Seems like it'd be easy but, like I said I'm new to regex.

Thanks!

Jul 21 '05 #2

P: n/a
"en*****@yahoo.com" wrote:
I need a regular expression that will
validate what people are entering as their new password.

Must be between 6 and 10 characters
Must be alphanumeric only
Can not be the word "password" in any case ie "pAsSworD" should also be
denied.


Try

^((?<password>password)|[a-z0-9]{6,10})$

with the IgnoreCase and ExplicitCapture options.

If the "password" group (group 1) matches successfully, then the user
entered password. Otherwise, a successful match is a valid password.

--

www.midnightbeach.com
Jul 21 '05 #3

P: n/a
Jon's suggestion will work if you have access to the match group in code. If
you are using this with a validation control, you normally would not have
access to this and could use something like this instead:

^(?!password$)[a-z0-9]{6,9}$

This uses "negative lookahead" to reject any string that is just the word
"password". As in Jon's example, use IgnoreCase. I assume from the original
message that "passwordX" would be a legitimate password and have allowed
this case, if not, it is easy to modify the regex to reject it.

I tested this in Expresso, but recommend the newest version, available at:

http://ultrapico.com
"Jon Shemitz" <jo*@midnightbeach.com> wrote in message
news:42***************@midnightbeach.com...
"en*****@yahoo.com" wrote:
I need a regular expression that will
validate what people are entering as their new password.

Must be between 6 and 10 characters
Must be alphanumeric only
Can not be the word "password" in any case ie "pAsSworD" should also be
denied.


Try

^((?<password>password)|[a-z0-9]{6,10})$

with the IgnoreCase and ExplicitCapture options.

If the "password" group (group 1) matches successfully, then the user
entered password. Otherwise, a successful match is a valid password.

--

www.midnightbeach.com

Jul 21 '05 #4

P: n/a
Oops! I meant to allow 10 alphanumerics, not 9. Here is the corrected regex:

^(?!password$)[a-z0-9]{6,10}$
"Jon Shemitz" <jo*@midnightbeach.com> wrote in message
news:42***************@midnightbeach.com...
"en*****@yahoo.com" wrote:
I need a regular expression that will
validate what people are entering as their new password.

Must be between 6 and 10 characters
Must be alphanumeric only
Can not be the word "password" in any case ie "pAsSworD" should also be
denied.


Try

^((?<password>password)|[a-z0-9]{6,10})$

with the IgnoreCase and ExplicitCapture options.

If the "password" group (group 1) matches successfully, then the user
entered password. Otherwise, a successful match is a valid password.

--

www.midnightbeach.com

Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.