用于验证名字和姓氏的PHP正则表达式[重复]

This question already has an answer here:

I am trying to use regex to validate the users first and last name on a form.

Rules

  • Must be alphabetic
  • First letter can either by uppercase or lowercase
  • Followed by all lowercase letters
  • Must be at least 2 letters long and cannot be longer than 15 letters.
  • No spaces.

This is my attempt at the regular expression

!preg_match('/^[a-Z]{1}[a-z]{1,14}$/' 

But I am getting the error:

: preg_match(): Compilation failed: range out of order in character class at offset 4

</div>

a-Z isn't a valid range, you need to change this to include both uppercase and lowercase ranges.

change to this: ^[a-zA-Z][a-z]{1,14}$