import restrn = "word hereword word, there word"search = "word"print re.findall(r"\b" + search + r"\b", strn)
Standard input is empty
['word', 'word', 'word']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!