我使用^$|^[^\s]+(\s+[^\s]+)*$
来实现:
但是如何将量词用于限制字符数在6-20之间?
以下内容应通过
"" <-- (empty string)
"中文" <-- ( any character)
"A B" <-- (allow space in middle)
"hi! Hello There"
以下内容应失败
"A" <-- (less than 2 number of characters)
" AB" <-- (space at the start)
"AB " <-- (space at the end)
" AB "
"test test test test test test" <--- (more than 20 characters included spaces)
谢谢!
答案 0 :(得分:4)
答案 1 :(得分:2)