C# Regex: Checking for “a-z” and “A-Z”

Regex reg = new Regex("^[a-zA-Z]+$");
  • ^ start of the string
  • [] character set
  • \+ one time or the more
  • $ end of the string

^ and $ needed because you want validate all string, not part of the string

Leave a Comment