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.
\\bleads?\\b
is all you need. \\b
is a word boundary, which means the word ends at the boundary.
s?
is an optional s
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.