string max length regex help

In the language ColdFusion I have an expression where I am validating Upper, Lower, Number, Special, Min Length, but I can't get Max Length to work.
I am adding a number - 10 for ex - after the 6, in the expression, but to no avail.
Is this the correct syntax?
Any ideas?

And yes - I want it in the same expression not by testing len(string) ...

LVL 25
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

dgrafxAuthor Commented:
I had tried that - got it from Googling - and it doesn't work ...
What does it match that it should not, or what does it not match that it should?
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

dgrafxAuthor Commented:
the max length - that's what this question is ...
You can check your regular expression syntax using the following online tool:

Typically the following should work for dealing with length:
Exact Length - Consist of exactly ten letters

Length Range - Consist of a minimum of three letters and a maximum of ten

Minimum Length - Consist of at least three letters
dgrafxAuthor Commented:
hey guys
I did find online examples but as I said I can't get the max length to work.
Any ideas on why my regex isn't working as intended?
The language is CF

Which CF tag or function are you using with the regex? Do you have a code snippet to share?
dgrafxAuthor Commented:
<cfset regex="(?=.*[A-Z])(?=.*[~!@##$%^&*_+=?-])(?=.*[0-9])(?=.*[a-z]).{6,}">
REFind(regex, form.password)

It seems as if it is working as intended except for max length which i have attempted like so:
<cfset regex="(?=.*[A-Z])(?=.*[~!@##$%^&*_+=?-])(?=.*[0-9])(?=.*[a-z]).{6,10}">
<cfset regex="(?=.*[A-Z])(?=.*[~!@##$%^&*_+=?-])(?=.*[0-9])(?=.*[a-z]).{6,10}$">

Try the following regex. It appears to work with my four test cases.

<cfparam name="form.password1" default="L_a~l5"> <!--- Meets min length --->
<cfparam name="form.password2" default="L_a~lor16@A"> <!--- Too long --->
<cfparam name="form.password3" default="L_a"> <!--- Too short --->
<cfparam name="form.password4" default="L*a4YtG6%h"> <!--- Meets max length --->

<p><strong>Test 1 - Meets min length</strong></p>
<cfset regex="^((?=.*[A-Z])(?=.*[~!@##$%^&*_+=?-])(?=.*[0-9])(?=.*[a-z]))(.{6,10})$">
<p><cfoutput>#REFind(regex, form.password1)#</cfoutput> </p>

<p><strong>Test 2 - Too long</strong></p>
<cfset regex="^((?=.*[A-Z])(?=.*[~!@##$%^&*_+=?-])(?=.*[0-9])(?=.*[a-z]))(.{6,10})$">
<p><cfoutput>#REFind(regex, form.password2)#</cfoutput> </p>

<p><strong>Test 3 - Too short</strong></p>
<cfset regex="^((?=.*[A-Z])(?=.*[~!@##$%^&*_+=?-])(?=.*[0-9])(?=.*[a-z]))(.{6,10})$">
<p><cfoutput>#REFind(regex, form.password3)#</cfoutput> </p>

<p><strong>Test 4 - Meets max length</strong></p>
<cfset regex="^((?=.*[A-Z])(?=.*[~!@##$%^&*_+=?-])(?=.*[0-9])(?=.*[a-z]))(.{6,10})$">
<p><cfoutput>#REFind(regex, form.password4)#</cfoutput> </p>

Open in new window

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
dgrafxAuthor Commented:
This appears to work perfectly - Thanks!
dgrafxAuthor Commented:
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
ColdFusion Language

From novice to tech pro — start learning today.