Match exact words in VSCode

Viewed 1641

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?

1 Answers

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

Related