preg_match username validation regex allows > and < despite those characters not being whitelisted

前端 未结 2 1767
既然无缘
既然无缘 2020-12-20 03:50

I have this relatively simple regex for usernames

// Enforce that username has to be 3-100 characters, alphanumeric, and first character a letter.
// Possibi         


        
2条回答
  •  独厮守ぢ
    2020-12-20 04:07

    +-_ is your problem. You need to escape the - in a character class or move it to the end or beginning of the class.

    For example:

    /^[a-z][a-z0-9@.+_-]{2,100}\z/i
    

提交回复
热议问题