RegEx for no whitespace at the beginning and end

后端 未结 14 1144
傲寒
傲寒 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:24

    How about:

    ^\S.+\S$
    

    This will match any string that doesn't begin or end with any kind of space.

提交回复
热议问题