473,498 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4344
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
9700
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
3408
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
396
by: Du Dang | last post by:
Text: ===================== <script1> ***stuff A </script1> ***more stuff <script2> ***stuff B
17
3940
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
268
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
5076
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated...
6
5848
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
2562
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
4188
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
7126
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6891
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7381
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5465
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4916
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4595
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
659
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.