Javascript Regular Expression “Single Space Character”

前端 未结 4 1936
礼貌的吻别
礼貌的吻别 2020-12-09 01:49

I am learning javascript and I am analyzing existing codes.

In my JS reference book, it says to search on a single space use \"\\s\"?

But I have

4条回答
  •  一个人的身影
    2020-12-09 02:17

    No. It is perfectly legal to include a literal space in a regex.

    However, it's not equivalent - \s will include any whitespace character, including tabs, non-breaking spaces, half-width spaces and other characters, whereas a literal space will only match the regular space character.

提交回复
热议问题