Regular expression to validate username

后端 未结 10 969
温柔的废话
温柔的废话 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:09

    A slight modification to Phillip's answer fixes the latest requirement

    ^[a-zA-Z0-9]([._](?![._])|[a-zA-Z0-9]){6,18}[a-zA-Z0-9]$
    

提交回复
热议问题