I need a regular expression for a password to fulfill the following requirements:
- It must be at least 6 characters long
- There must be 1 numeric character
- The first and last character must be an alphabetic character
- No special characters
I’ve found some expressions that come close to this, but none that match what I need.
Any help you can provide would be greatly appreciated.
I’ve tried this but it doesn’t quite fit the bill:
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$
Assert that a string has 6 or more characters:
(?=.{6,})Assert that a string has at least 1 numeric character:
(?=.*\d)Match an alphabetic character in the first and last position:
^[A-Za-z].*[A-Za-z]$Combining all of the above, yields the following final expression: