Regex To Match A String That Contains At least 1 Number And 1 Character

A Regular Expression to match a string containing at least 1 number and 1 character. Typically used to validate complex passwords or usernames.

/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/

Matches:

  • RegexPattern1
  • 1RegexPattern
  • Regex1Pattern

Non-matches:

  • RegexPattern1%
  • RegexPattern

See Also:

Regex Is Copied!