[Solved] Regular expression to validate input from 4 or 5 character the first 3 should be alwas letters [closed]


The regular expression could look like this:

^[a-zA-Z]{3}[0-9]{1,2}$
  • ^ is denoting the beginning of the string
  • [a-zA-Z] is a character class that includes all uppercase and lowercase letters from A to Z
  • {3} requires three consecutive occurences of that aforementioned character class
  • [0-9] is a character class that includes all numbers from 0 to 9
  • {1,2} requires at least one, maximum two consecutive occurences of that character class
  • $ is denoting the end of the string
<form>
<input type="text" pattern="^[a-z]{3}[0-9]{1,2}$" maxlength="5" required />
<input type="submit" />
</form>

4

solved Regular expression to validate input from 4 or 5 character the first 3 should be alwas letters [closed]