Text Processing
Positive Lookahead (Password)
Use positive lookahead `(?=...)` to require the password contain at least one digit and one uppercase letter.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
^(?=.*\d)(?=.*[A-Z])[A-Za-z\d]{8,}$Raw source: ^(?=.*\d)(?=.*[A-Z])[A-Za-z\d]{8,}$
How it works
(?=.*\d) is a zero-width assertion that requires the rest of the string to contain a digit somewhere. (?=.*[A-Z]) similarly requires an uppercase letter. Neither consumes characters. [A-Za-z\d]{8,}$ then matches the actual password content (≥8 alphanumerics). Lookaheads are supported in JS and Python; Go's RE2 does NOT support them.
Examples
Input
Password1Matches
Password1
Input
weakpassNo match
—Input
ALLCAPSNODIGITNo match
—Common use cases
- •Password complexity enforcement
- •Form validation with multiple co-required tokens
- •Filename validation (must end with extension AND start with letter)
- •Compound-rule input filtering
Related patterns
Negative Lookahead
Text ProcessingUse negative lookahead `(?!...)` to match words that are NOT in a blocklist (here: log-level keywords).
Password (No Special Chars)
ValidationValidate passwords requiring at least one lowercase, one uppercase, one digit, and minimum 8 characters — no special characters required.
Negative Lookbehind (Decimals Without $)
Text ProcessingUse negative lookbehind `(?<!...)` to match decimal numbers NOT preceded by a dollar sign.
Non-Capturing Group (Image URL)
Text ProcessingUse non-capturing groups `(?:...)` to alternate without polluting the captured-groups list.