- Should be at least 4 characters
(至少应包含4个字符)
- Should start with a character
[a-zA-Z]
(应以字符[a-zA-Z]
开头)
- Should not end with
_
(不应以_
结尾)
- Should only contain at most 1
_
in the entire word (整个单词中最多只能包含1个_
)
- The word can contain
[a-zA-Z0-9]
(该词可以包含[a-zA-Z0-9]
)
I tried the following regex:
(我尝试了以下正则表达式:)
^[a-zA-Z][a-zA-Z0-9]*_?[a-zA-Z0-9]*[^_]$
But then I am wondering wether this could be made even smaller, and also I am not sure how do I set 'atleast 4 characters' constraint.
(但是然后我想知道是否可以使它更小,而且我不确定如何设置“至少4个字符”约束。)
ask by Ranjandas translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…