Reputation: 1008
I want regex that will match "lead" or "leads" and will not match when it's part of another word like cheerleaders or leaders. I also don't want whitespaces matched before or after the word.
The closet I got was /(?:^|\W)Lead(?:$|\W){0,5}/g;
But this matches Leaders and whitespaces. This is in javascript if that makes a difference.
Upvotes: 2
Views: 4772
Reputation: 1778
\bleads?\b
is all you need. \b
is a word boundary, which means the word ends at the boundary.
s?
is an optional s
Upvotes: 6