How to validate a user name with regex?

后端 未结 10 1727
礼貌的吻别
礼貌的吻别 2020-11-27 12:34

This seems to match the rules I have defined, but I only starting learning regex tonight, so I am wondering if it is correct.

Rules:

  • Usernames can cons
10条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 13:30

    In my opinion, adding a limited scope to this model would be better

    [a-zA-Z0-9]+([_ -]?[a-zA-Z0-9]){5,40}$

提交回复
热议问题