I am attempting to match words within a string however I do not want to match words that are part of another word... poor explanation, onto the example!
If have the word pen
. I want to match that word within a string:
01pennsylvania'
should not match as pen
is part of the word pennsylvania
.
However, pensforsale
should match as pen
isn't part of another word. I've been looking into NLTK but I can't find what I'm looking for, can anyone point me in the right direction? I know it would be impossible to do this for all word combinations but cutting down the noise marginally would be a great help.
Thanks in advance!