Home > Back-end >  Weird behavior in VS code regex search
Weird behavior in VS code regex search

Time:02-01

Has anyone notice this weird behavior in vscode regex search or im using it wrongly? The regex search in vscode is matching "space" in between the characters and when i was traversing between the matches with the arrow key it will jump from 1st match to the 3rd match etc.

text string: abcdefg
regex: [a]*

I have upload a video demonstrating the behavior

https://www.awesomescreenshot.com/video/7134796

CodePudding user response:

The issue here is that [a]* matches zero or more letter a's. This means that zero width markers in between letters are also a match. You should use [a] here, which means one or more letter a's.

See the demo here for the behavior you probably want.

  •  Tags:  
  • Related