Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2008, 09:09 AM
Registered User
 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Regular expression for password?

Hi,
anyone who could help me with a regular expression for a password which has these requirements:
- max 15 characters (both text,numbers and other characters like _ % etc)
- cannot contain comma or semi-colon ( , ;). All other characters are allowed.

Doesn't seem too complicated, but i have no experience with regular expressions, so any help is really appreciated!



 
Old October 3rd, 2008, 07:58 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Have you tried google yet? There are many online resources for learning regular expressions.

-Peter
compiledthoughts.com
 
Old October 3rd, 2008, 08:23 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

This is pretty simple, as you have stated it:
    "^[^\,\;\s]{1,15}$"
or, if using C#:
    "^[^\\,\\;\\s]{1,15}$"

I also disallowed spaces (besides comma and semicolon).

But are you SURE this is what you want? It means that all of the following passwords are *LEGAL*:
    a
    ?
    Â©
    Â©Â©Â©Â©Â©
    ?©
    1
    Â©Â©Â©Â©Â©Â©Â©Â©Â©Â©Â©Â©Â©Â©Â©Â©Â©Â©

Is that REALLY what you want????

Most companies are much more restrictive. MS rules, for example:

Minimum of 6 characters, maximum of 18 [not sure about that max]
Must contain at least one upper case letter
Must contain at least one lower case letter
Must contain at least one digit
Must contain at least one non-alphanumeric character [I think chosen from a list, but not sure]

Now *THAT* is a much more reasonable "strong password". And it's also a much much tougher regular expression, though I believe it *is* doable.

[By the way: Why are comma and semicolon, of all things, disallowed??? I would see apostrophes and maybe quotes, but those characters? Why?]





Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Help Please rstelma ASP.NET 1.0 and 1.1 Professional 0 January 2nd, 2008 07:01 PM
Regular Expression for a password? Jeff Mason VB.NET 6 May 18th, 2007 10:59 AM
Password Validation with Regular Expression moghazali ASP.NET 1.0 and 1.1 Basics 0 January 7th, 2007 04:50 AM
Regular Expression for password kitkits ASP.NET 1.0 and 1.1 Basics 2 April 28th, 2005 11:44 PM
Regular Expression for password Baby_programmer ASP.NET 1.0 and 1.1 Basics 1 December 28th, 2004 01:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.