Regex To Check If A String Is All Uppercase (Or Lowercase)

A regular expression to check if a string is all uppercase (or lowercase) letters.

Uppercase

/^[^a-z]*$/

Matches:

  • REGEX
  • REGEXPATTERN
  • ABCD

Non-Matches:

  • regex
  • regexpattern
  • RegexPattern

Lowercase

/^[^A-Z]*$/

Matches:

  • regex
  • regexpattern
  • RegexPattern

Non-Matches:

  • REGEX
  • REGEXPATTERN
  • ABCD

See Also: