我有一个文本框字段,我想规范输入的内容。
我不希望用户键入更多或更少的 6-10 个字符。 这是我限制字符 ^ 的正则表达式。{6,10}$ 我让这部分工作,但我也不希望用户输入空格(空格)。现在,我能够从输入的开头和输入的结尾检测到空格,但如果用户在文本中间键入空格,则无法检测到空格。请参阅示例。
" testing" = regulator detects the space in the beginning. regex i use ^[^s].+[^s]$
"testing " = regulator detects the space in the end. regex i use here is same as abow
"test ing" = regulator does not detect the space in the middle. tried different regex with no luck.
我怎样才能创建一个能够完成我所需要的一切的调节器?
这是您的.
的问题,它与所有内容相匹配
这样做
^[^s]{6,10}$
[^s]
匹配除space
以外的任何字符
或
^w{6,10}$
w
类似于[da-zA-Z_]
Some1.Kill.The.DJ 答案很好,但对于您的个人知识,您还可以使用以下方法:
^S{6,10}$
S
以与[^s]
相同的方式匹配除space
以外的任何字符