Build a password validation regex

Check a password against explicit length and character-class rules.

freeworks offlinenothing uploaded
ToolPassword Regex
Input
Output

How it works

Lookaheads require selected character classes and a minimum length while a consuming expression matches the complete password. The result checks policy shape, not entropy or breach history.

  • Length and class requirements remain adjustable by policy.
  • The consuming match prevents extra characters outside the policy.

Worked example

Strong password with all character types required
Generate a regex for passwords requiring 8+ chars with uppercase, lowercase, digit, and special character
Input
											Min length: 8
Require uppercase: true
Require lowercase: true
Require digit: true
Require special: true
Max length: 128
										
Output
												Password Regex:

^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]).{8,128}$

Requirements:
  - Length: 8-128 characters
  - at least one uppercase letter
  - at least one lowercase letter
  - at least one digit
  - at least one special character
											

When to use this

Signup forms, identity-provider policies, and validation tests check password shape.

Edge cases

  • A long passphrase can fail composition rules.
  • Unicode letters may not match ASCII classes.
  • A regex-approved password can still be breached.