Community Patterns

Community Library Entry

2

Regular Expression
Created·2015-02-22 20:57
Flavor·PCRE (Legacy)

/
(?=^.{8,32}$)(?=.*\d)(?=.*[!@#$%^&*]+)(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$
/
Open regex in editor

Description

This RegEx was posted on a Ruby site as one for enforcing password pattern. I added {8,32} to limit the length of the password, even though I realize no one has passwords longer than that. Rules: at least 1 digit, 1 special character (as defined), 1 upper case and 1 lower case character, between 8 and 32 characters total.

The question I have pertains to the trailing .*$ pattern. On the Rubular site, this is required. On regex101.com it does not see to add value to the regex.

Do I need the .*$ on the expression?

Submitted by Dave Phillips