- 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