RegEx for no whitespace at the beginning and end

后端 未结 14 1150
傲寒
傲寒 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

    This is the regex for no white space at the begining nor at the end but only one between. Also works without a 3 character limit :

    \^([^\s]*[A-Za-z0-9]\s{0,1})[^\s]*$\ - just remove {0,1} and add * in order to have limitless space between.

提交回复
热议问题