Regular expression to validate username

后端 未结 10 953
温柔的废话
温柔的废话 2020-11-28 19:27

I\'m trying to create a regular expression to validate usernames against these criteria:

  1. Only contains alphanumeric characters, underscore an
10条回答
  •  [愿得一人]
    2020-11-28 20:14

    ^[a-z0-9_-]{3,15}$

    ^ # Start of the line

    [a-z0-9_-] # Match characters and symbols in the list, a-z, 0-9, underscore, hyphen

    {3,15} # Length at least 3 characters and maximum length of 15

    $ # End of the line

提交回复
热议问题