Regex to check if the first character is uppercase

前端 未结 5 1829
忘了有多久
忘了有多久 2021-02-13 13:37

I\'m trying to check that the first character of a username is capital, the following can be letters or numbers and at most 20 characters long. Can someone explain why my synta

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-13 14:26

    Your first character needs to be A-Z, not A-z

    So

    /^[A-z][a-z0-9_-]{3,19}$/

    Should be

    /^[A-Z][a-z0-9_-]{3,19}$/

提交回复
热议问题