To match a specific word in a regular expression, you can simply use the word itself as the pattern. If you want to ensure that the match is for the whole word and not part of another word, you can use word boundaries, represented by \b.
For example, to match the word "apple", you can use the following regular expression:
\bapple\b
This pattern will match "apple" when it appears as a standalone word, but it will not match it in words like "apples" or "pineapple".
Here are some examples:
- The string "I have an apple." will match.
- The string "I have apples." will not match.
- The string "I like pineapple." will not match.
