Test a password policy pattern with synthetic examples
Admin ·
A password policy regex can express length and composition rules in a form you can test. Use synthetic character strings to isolate a specific rule and verify what the exported JavaScript literal matches.
Build a restricted ASCII recipe
Choose Load example. The recipe allows 10 to 16 ASCII code points, requires uppercase, lowercase, digit and symbol groups, and allows only the three punctuation marks !, - and ]. Build the pattern.
Enable Test a synthetic string. Enter Lantern7!crew and build again. The test reports 13 code points and a match. Replace ! with ? and test again. The input now fails both the allowed-character rule and the required-symbol rule.
Lantern7!crewRead the anchors, lookaheads and length range
The ^ assertion starts the pattern at the start of the string. The last assertion, (?![\s\S]), succeeds only when no character remains. Between them, the bounded positive lookaheads search for the required character groups and the final quantified class consumes the allowed input.
The example encodes its punctuation as hexadecimal escapes so ] and - stay literal characters inside a class. Keep the u flag and test the exported literal in your ECMAScript runtime. Other engines and HTML pattern validation can use different syntax and flags.
ECMAScript regular-expression patternsHTML input pattern attribute
Compare Unicode text and account policy decisions
In Unicode mode, length counts code points. The single emoji 😀 counts as one code point, while a sequence joined from several code points counts as several. Uppercase and lowercase use Unicode case properties, decimal digits use Nd, and punctuation and symbols form the symbol group.
Composition requirements check the syntax you choose. NIST SP 800-63B-4 prohibits composition rules for password verifiers within its scope and describes additional verifier controls. Use this workspace to inspect literal requirements for a system you own.
ECMAScript regular-expression patternsNIST SP 800-63B-4, password verifiers
Common questions
Can I copy the pattern out without the synthetic sample?
Copy or download exports only the regex literal. The synthetic input and its test result stay in the workspace.
Why does allowing whitespace differ across modes?
ASCII mode optionally permits ordinary spaces. Unicode mode optionally permits ECMAScript whitespace and always excludes Unicode control characters and unpaired surrogates.