Javascript regex - no white space at beginning + allow space in the middle

后端 未结 8 1707
故里飘歌
故里飘歌 2020-12-16 15:15

I would like to have a regex which matches the string with NO whitespace(s) at the beginning. But the string containing whitespace(s) in the middle CAN match. So far i have

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 15:37

    /^[^.\s]/

    • try this instead it will not allow a user to enter character at first place
    • ^ matches position just before the first character of the string
    • . matches a single character. Does not matter what character it is, except newline
    • \s is space

提交回复
热议问题