password validation - no repeating patternsmore than twice in succession

Hi experts:
I have a requirement to validate passwords using the usual criteria, but one interesting one.  I must make sure the password does not contain characters repeating more than once in a succession.  The password can only be 20 characters long.  The requirement means the following:
Legal passwords may contain: abcabc, dd, !&!&, rere

Illegal passwords: abcabcabc, ddd, !&!&!&, rerere

I hope this makes sense.  I am working in coldfusion 8.  I am trying to use a regular expression, but I think I need to do some sort of recurssion.

Any ideas?  Thanks in advance.  If you could point me in the right direction, that would be a big help.
snix123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pui_YunCommented:
Hi snix,
Try this regex:
^(.+?)(\1)$
The adobe website has an example of capturing repeating words here:
https://www.adobe.com/livedocs/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/regexp4.htm#1099092

Read the section on using backreferences.

Hope this helps.
P.
0
käµfm³d 👽Commented:
I am a bit confused by your requirement, so I am posting two patterns--you can pick which applies to you  :)

Both validate that the string is 20 characters.
// This will match if a series of characters
//  are found repeating twice anywhere in
//  the string (e.g. abchelloabcthereabc)
^(?=.*?(.+).*?\1.*?\1.*?).{1,20}$


// This will match if a series of characters
//  are found repeating twice immediately in
//  succession (e.g. abcabcabc)
^(?=.*?(.+)\1\1.*?).{1,20}$

Open in new window

0
snix123Author Commented:
Thank you.  I already have the 20 characters limit working.  For the second pattern, I think I would just try to use this: ^(?=.*?(.+)\1\1.*?) since I don't need to test the length here.  Can't seem to make it work without testing length, too.  

I will play around with it.  The backreferenceing doc is helping, too.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

käµfm³d 👽Commented:
You would need to remove the look-ahead I placed in there--the (?= ...) part. The pattern you need would be:
^.*?(.+)\1\1.*?$

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
snix123Author Commented:
Thanks to all: this is looking pretty good.  
0
käµfm³d 👽Commented:
NP. Glad to help :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.