Skip to Content

RegEx Troubles

Dear Experts,

I'm trying to use a RegEx to validate an attribute value. It's going to be storing a password but not inside the standard MX_PASSWORD or MX_ENCRYPTED_PASSWORD attributes. It's for a custom attribute. Not sure if that matters but full disclosure here.

My test password is: abcd123$

The requirements are 8 characters long, 1 letter (case-insensitive), 1 number and a special character that is one of these three: $_#

My test password should work but I've entered the following RegEx values and it's getting rejected every time:

((?=.*[0-9])((?=.*[A-Z])|(?=.*[a-z]))(?=.*[#$_]))

(?=.*\d)(?=.*[a-zA-Z])(?=.*[#_$])

I’ve tried the above expressions with a leading carrot as well:

^((?=.*[0-9])((?=.*[A-Z])|(?=.*[a-z]))(?=.*[#$_]))

^(?=.*\d)(?=.*[a-zA-Z])(?=.*[#_$])

I’ve also tried these with an escape for the $ character as that is technically a special character. It shouldn’t matter while contained in the brackets but I tried anyway since my test password contains a dollar sign:

((?=.*[0-9])((?=.*[A-Z])|(?=.*[a-z]))(?=.*[#\$_]))

Lastly, here's a pic of the validation tab setup for my attribute:

Anyone have any suggestions? What am I doing wrong?

capture.png (17.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 01, 2017 at 06:39 PM

    A co-worker found the answer. Here's the string that worked:

    ^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[#$_])[a-zA-Z0-9#$_]{8,}$

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 01, 2017 at 02:46 AM

    Did you look at any of the online tools?

    https://regex101.com/

    http://www.rubular.com/

    http://buildregex.com

    No RegEx expert, but it might be helpful.

    Add comment
    10|10000 characters needed characters exceeded

    • I do like the Rubular site for testing purposes. When you plug in a RegEx, you can then enter password trials in the box and see if the RegEx will validate it or not. I'll be using that site in the future for testing my RegEx strings.