Regular Expression Help!

Soldato
Joined
5 Mar 2003
Posts
10,769
Location
Nottingham
Hello all!
I have to produce a regular expression whichs validates a password against the following:
  • 8 to 12 character long
  • Can’t start with a digit
  • No more then two consecutive characters can be identical.
  • Alpha Numeric only.

My best attempt is:
(\b(?=\w{8,12}\b)(?=(\w)(?!=\1\1))[a-zA-Z]\w*

but it doesnt work in all situations... the real problem is the two consecutive chars... Is there a way to make a look ahead only apply to the result from a previous look ahead - or does that just give (internally) a true or false and either proceeds or skips?
Thanks in advance :)
 
Yeah its the consecutive one thats the problem... done the others pretty easy. The problem is with words like "ggeeeeeee"; the expression looks at g, checks the next two chars.... one is an 'e' so it passes the look ahead. Need a way to look at each character, check infront of it two places and if there are any repetitions for each of the checked chars the whole regex should fail.

As it is, if there is one pass, the whole thing passes.
 
Back
Top Bottom