Regex for Strong Password (8+ Chars)

Production-ready password strength regex using positive lookaheads to enforce lowercase, uppercase, numeric digit, and symbol requirements.

/

⚡ Live Interactive Sandbox

Validation Result: MATCH ✓

Pattern Breakdown & Tokens

  • • (?=.*[a-z]) — requires at least one lowercase alphabetical character
  • • (?=.*[A-Z]) — requires at least one uppercase letter
  • • (?=.*\d) — requires at least one numerical digit
  • • (?=.*[@$!%*?&]) — requires at least one special symbol
  • • .{8,}$ — ensures minimum length of 8 total characters

Code Snippets

JavaScript
const passRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
const isStrong = passRegex.test(password);
Python
import re
pattern = r"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$"
is_strong = bool(re.match(pattern, password))
Go (Golang)
matched, err := regexp.MatchString(`^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$`, password)
PHP
$isStrong = preg_match('/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/', $password);

Open the full tool: Open Full Regex Tester →

FAQ

How does this regular expression for Strong Password (8+ Chars) work?

Production-ready password strength regex using positive lookaheads to enforce lowercase, uppercase, numeric digit, and symbol requirements. The pattern is: ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$

How to use this regex in JavaScript and Python?

In JavaScript: new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$").test(input). In Python: re.match(r"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$", input).

Can I test complex regular expressions online?

Yes, use our full in-browser Regex Tester tool with live syntax highlighting, group capture table, and zero server uploads.

🔗 Share this page

TelegramWhatsAppX