RegEx for no whitespace at the beginning and end

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

    pattern="^[^\s]+[-a-zA-Z\s]+([-a-zA-Z]+)*$" This will help you accept only characters and wont allow spaces at the start nor whitespaces.

提交回复
热议问题