An expression to match roosteror henas a complete word (i.e. not when they are part of a longer and different word):
\b(rooster|hen)\b
This is a safety measure to avoid false positives with partial matches.
\bdenotes the word boundary , which is the (zero width) spot between the character in the range of the "character of the word" ( [A-Za-z0-9_]) and any other character. In fact, the above would be:
- corresponds to
"A chicken is either a rooster or a hen." "Chickens are either a roosters or hens." - (rooster|hen)
, , : \b(roosters?|hens?)\b