I have a list of whitelisted words: kitchen chair table;
Given a text, I would like to know which of those white-listed words are in it.
What would be a good way to achieve this? I mean, easy to understand, with good performances?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To achieve this, you should use a regex with word boundaries. If you don’t and just rely on string positions, words like “heat” will be matched inside words like “cheat”
This outputs:
Note that this will not match
tableif the$textonly hadtablesin it.