472,776 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,776 software developers and data experts.

vb.net regex question

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
4 4283
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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
2
by: Tim Conner | last post by:
Hi, Thanks to Peter, Chris and Steven who answered my previous answer about regex to split a string. Actually, it was as easy as create a regex with the pattern "/*-+()," and most of my string...
6
by: Du Dang | last post by:
Text: ===================== <script1> ***stuff A </script1> ***more stuff <script2> ***stuff B
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
4
by: engwar1 | last post by:
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...
5
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated...
6
by: Martin Evans | last post by:
Sorry, yet another REGEX question. I've been struggling with trying to get a regular expression to do the following example in Python: Search and replace all instances of "sleeping" with "dead"....
7
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward...
6
by: Phil Barber | last post by:
I am using Regex to validate a file name. I have everything I need except I would like the dot(.) in the filename only to appear once. My question is it possible to allow one instance of character...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.