James Ives
James Ives

Reputation: 3355

Match exact words in VSCode

I'm doing a find and replace in VSCode for some CSS classes and I'm running into the following issue when matching for the word row. It finds row successfully, but I'm trying to avoid it from also matching things like row-label. Is there a way to match strings that only includes things such as row and .row?

Upvotes: 6

Views: 2410

Answers (1)

Mark
Mark

Reputation: 180765

Try (?<![\w-])(row)[^-\w]

Negative lookbehind to eliminate \w or - from immediately preceding row.

And following character cannot be \w or -.

Rex101 demo


If necessary to avoid row followed by characters such as ! or $ etc. you could use

(?<![\w-])(row)[^-\w!@$%^&*)_+\-=\[\]{};':"\\|,.\/?]

https://regex101.com/r/tUMNOu/10

Upvotes: 3

Related Questions