Regexp Validation

  • Thread starter Thread starter fdisk
  • Start date Start date
F

fdisk

Oh great Regular Expression gurus - I summon thee...

I am using the regular expression validator...

I know this is probably about as trivial as it gets for someone with
regular expression experience, but I don't. I was wondering if
someone would be able to create a regular expression (for validating
user passwords) that matches the following:

All of the following must be true for a match:

6-12 length - Isn't it something like {6,12}
Must include 1 or more lowercase - [a-z]
Must include 1 or more uppercase - [A-Z]
Must include 1 or more numeric - [0-9]

That's it, from the little I know, those are the patterns that it
should use, but I have no idea how to create the full statement.

TIA!

JB
 
..net regular expressions have a handy feature called "lookahead":
Use a RegEx like this
"^(?=.*[a-z])
(?=.*[A-Z])
(?=.*[0-9])
.{6,12}$"
(turn on the "ignore whitespace option" or remove the spaces/newlines)

First of all '^' matches the beginning of the string.
Read '(?=...)' as "match '...' at the current position, without changing the
current position"
That is ".*[a-z]" is matched at the beginning of the string;
Next, ".*[A-Z]" is matched at the beginning of the string;
Next, ".*[0-9]" is matched at the beginning of the string;
finally any character ('.') is matched 6-12 times, followed by the end of
the string '$'.

Note that
- this is extremely slow when used on big sets of data
- this is a special .net-feature that's not common in other RegEx engines

Niki
 
Niki Estner said:
.net regular expressions have a handy feature called "lookahead":
Use a RegEx like this
"^(?=.*[a-z])
(?=.*[A-Z])
(?=.*[0-9])
.{6,12}$"
(turn on the "ignore whitespace option" or remove the spaces/newlines)

First of all '^' matches the beginning of the string.
Read '(?=...)' as "match '...' at the current position, without changing the
current position"
That is ".*[a-z]" is matched at the beginning of the string;
Next, ".*[A-Z]" is matched at the beginning of the string;
Next, ".*[0-9]" is matched at the beginning of the string;
finally any character ('.') is matched 6-12 times, followed by the end of
the string '$'.

Note that
- this is extremely slow when used on big sets of data
- this is a special .net-feature that's not common in other RegEx engines

Niki
Thanks for the response Niki, but I can't seem to get it to work
properly within the regex validation control - always seems to fail,
are you able to get this to work properly? I've seen this regex
before - from the regexlib website?
 
Back
Top