我用 ^$|^[^\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)
谢谢!
最佳答案
关于regex - 正则表达式在开始或结束时没有空格,但允许中间有空格,空和任何 6-20 个字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23559463/