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?
 
käµfm³d 👽Connect With a Mentor 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
 
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
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
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
 
snix123Author Commented:
Thanks to all: this is looking pretty good.  
0
 
käµfm³d 👽Commented:
NP. Glad to help :)
0
All Courses

From novice to tech pro — start learning today.