Regex match exact number not if it exist in string

前端 未结 2 1401
有刺的猬
有刺的猬 2020-12-12 06:28

My regex:

/3\\b/

Matches:

103

134,256,3

I want it to only match the lone 3. The number 3 will be a dyna

2条回答
  •  不思量自难忘°
    2020-12-12 06:53

    If you want to match only 3 in line you can use anchors like this:

    ^3$
    

    On the other hand if you want to match 3 in a line with more data you need to add an additional \b at your regex as Barmar showed in her answer

提交回复
热议问题