我需要编写一个正则表达式来验证文本输入。文本必须介于 5 到 16 个字符之间(a-Z 加上连字符、下划线和空格)。这很好,但它还必须检查是否没有任何连续的空格。
例如
hello // PASS
hello there // PASS
hi there you // PASS
hello there // FAIL - two spaces between hello and there
最佳答案
你可以使用类似的东西:
/^(?!.* )[-a-z_ ]{5,16}\z/i
关于javascript - 用于检查重复空格字符的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8150037/