Regex for password = one number and both lower and uppercase letters and special characters BUT!! no special characters at start or end
It's not that hard:
( # Start of group
(?=.*\d) # must contain at least one digit
(?=.*[A-Z]) # must contain at least one uppercase character
(?=.*[a-z]) # must contain at least one lowercase character
(?=.*\W) # must contain at least one special symbol
\w
. # match anything with previous condition checking
{6,18} # length is characters
\w
) # End of group
In one line:
((?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*\W)\w.{6,18}\w)
If you do not like \w
which is equal to [a-zA-Z0-9_]
replace it with that group and remove the underscore.
However, I fully support ctwheels' argument.
Password pattern wont accept this special characters like <>,./'";
(?=.*[0-9]) require one digit anywhere
(?=.*[a-z]) require one lowercase letter anywhere
(?=.*[A-Z]) require one uppercase letter anywhere
(?=.*[^0-9a-zA-Z]) require one symbol anywhere
^.{8,26}$ match any string of 8 to 26 characters
Combine all of these together and you get:
^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[^0-9a-zA-Z]).{8,26}$
This, of course, counts anything that isn't a letter from A to Z or a digit as a special character, including accented letters, letters from other alphabets, and whitespace.
Related Topics
React Open Modal Window on Click in Another Component
Vue.Js Refs Are Undefined, Even Though This.$Refs Shows Theyre There
Node.Js Document Is Not Defined
Postman Test - Validating String Values in an Object in an Array
Text Input Allow Only Integer Input in Angularjs
Multi Select Drop Down With Checkbox
Display a Loading Icon While Images Loads
Cors - Response to Preflight Request Doesn't Pass Access Control Check
Ant Design Range Picker Disable Array of Dates
Prevent CSS Tooltip from Going Out of Page/Window
What Does Webkitformboundary Mean
How to I Retrieve Last Part of Url and Use It in HTML
What Does an Exclamation Mark Before a Variable Mean in JavaScript
Hosting Your Own JavaScript Scripts Files (Other Than Jquery) on Fast Free Cdns Like Google
Export Method/Function in React Native