gpt4 book ai didi

javascript - 使用正则表达式验证用户名

转载 作者:行者123 更新时间:2023-11-29 16:43:00 25 4
gpt4 key购买 nike

  1. 用户名中唯一的数字必须在末尾。最后可以有零个或多个。

  2. 用户名字母可以是小写和大写。

  3. 用户名的长度必须至少为两个字符。两个字母的用户名只能使用字母字符。

我正在尝试这个,但我停滞不前。 /\d+$\w+/gi

最佳答案

/^[a-z]{2,}\d*$/i 是:

^     : the begining
[a-z] : a character (a to z), you can add as many allowed characters as you want
{2,} : at least 2 of them
\d* : 0 or more digits
$ : the end
i : ignore case sensetivity (both lowercases and uppercases are allowed)

关于javascript - 使用正则表达式验证用户名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43810615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com