RegexRef
🔑

Regex for Strong Password

Requires at least 8 characters, one uppercase, one lowercase, one number, and one special character.

The Pattern

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/
Test in Visualizer ↗

✅ Matches

  • StrongP@ss1
  • P4ssw0rd!

❌ Non-Matches

  • weakpass
  • OnlyUpper1
  • NoSpecialChar1

Implement in your Code

javascript
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
regex.test('StrongP@ss1');
python
import re
regex = re.compile(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$')
bool(regex.match('StrongP@ss1'))
go
import "regexp"
// Go regexp does not support lookarounds. Use another library or string checks.
rust
use regex::Regex;
// Rust regex crate does not support lookarounds. Use multiple checks instead.