Security

Strong Password

Enforce strong passwords: min 8 chars, at least one lowercase, uppercase, digit, and special character.

Try it in RegexPro →

Available in

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[^a-zA-Z\\d\\s]).{8,}$", "");
const input = "MyP@ssw0rd";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

Pattern

regexengine-agnostic
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^a-zA-Z\d\s]).{8,}$

Raw source: ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^a-zA-Z\d\s]).{8,}$

How it works

Uses four lookaheads from the start (^) to assert each required character class exists somewhere in the string, then .{8,} ensures minimum length, and $ anchors the end.

Examples

Input

MyP@ssw0rd

Matches

  • MyP@ssw0rd

Input

password123

No match

Input

SHORT1!

No match

Common use cases

  • User registration form validation
  • Password policy enforcement
  • Admin panel access controls
  • Security compliance checks

Related patterns

Related concepts