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?
Request clarification before answering.
A co-worker found the answer. Here's the string that worked:
^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[#$_])[a-zA-Z0-9#$_]{8,}$
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you look at any of the online tools?
No RegEx expert, but it might be helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried RegEx101.com and couple others but it was all kind of over my head. I like the BuildRegEx site but I still wasn't able to construct the proper string that I needed to get the result I wanted. In the end, a co-worker found the right answer for me. This is the string that worked:
^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[#$_])[a-zA-Z0-9#$_]{8,}$
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.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.