RegEx for no whitespace at the beginning and end

后端 未结 14 1172
傲寒
傲寒 2020-11-27 07:20

I want to design an expression for not allowing whitespace at the beginning and at the end of a string, but allowing in the middle of the string.

The regex I\'ve tri

14条回答
  •  被撕碎了的回忆
    2020-11-27 07:31

    ^[^0-9 ]{1}([a-zA-Z]+\s{1})+[a-zA-Z]+$
    

    -for No more than one whitespaces in between , No spaces in first and last.

    ^[^0-9 ]{1}([a-zA-Z ])+[a-zA-Z]+$
    

    -for more than one whitespaces in between , No spaces in first and last.

提交回复
热议问题