Skip to main content
Regexflux

Password Length Validation

beginner

Validates password length between 8 and 128 characters with any characters allowed.

passwordvalidationlength

Pattern

/^.{8,128}$/s

Try It

0 of 6 strings matched

Explanation

Matches any string between 8 and 128 characters long. The dotAll flag (s) allows dots to match newlines. No character type restrictions.

Test Strings

Matching

  • my-passphrase-is-long
  • 12345678
  • P@$$w0rd!

Non-matching

  • short
  • 1234567
  • ab

Language Compatibility

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull support

Code Snippets

const regex = /^.{8,128}$/s;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);

Common Variations

No spaces

^\S{8,128}$

Rejects passwords containing whitespace

Related Patterns