更新时间:2023-02-17 22:39:33
有几个问题:
\S
@
或 #
您可以通过使用否定前瞻来禁止句点/连字符/下划线的连续出现并从允许任何非空格字符的正则表达式中间删除 \S
来修复它
You can fix it by using a negative lookahead to disallow consecutive occurrence of period/hyphen/underscore and remove \S
from middle of regex that allows any non-space character
^[a-zA-Z0-9](?!.*[_.-]{2})[\w.-]{4,13}[a-zA-Z0-9]$