我^$|^[^\s]+(\s+[^\s]+)*$用来实现:
但是如何将量词限制在6-20之间?
以下内容应该通过
"" <-- (empty string)
"??" <-- ( any character)
"A B" <-- (allow space in middle)
"hi! Hello There"
Run Code Online (Sandbox Code Playgroud)
以下应该失败
"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)
Run Code Online (Sandbox Code Playgroud)
谢谢!