字母数字用户名的正则表达式模式



我想输入用户名字母数字字符串.

  • 字母和数字必须是字符串
  • 字符串应该以字母开头,以数字结尾。
  • 只能包含特殊字符下划线(可选)

我的代码
<input type="text" name="username" id="username" placeholder="Choose Username" 
pattern="^[a-zA-Z0-9_]+${7,25}" autocomplete="off" required>

你需要积极向前看

https://regex101.com/r/280p8a/1

^(?=w{7,25}$)[A-Za-z]w+d$)

Positive Lookahead (?=^.{7,25}$)
Assert that the Regex below matches
^ asserts position at start of a line
w matches any word character ([a-zA-Z0-9_])
{7,25} matches the previous token between 7 and 25 times, as many times as possible, giving back as needed (greedy)
$ asserts position at the end of a line

相关内容

  • 没有找到相关文章

最新更新