import rerx = r"\w+(?:\.\w+)*|[^\w\s]"s = "Mr.Smith is a professor at Harvard, and is a great guy."print(re.findall(rx, s))
Standard input is empty
['Mr.Smith', 'is', 'a', 'professor', 'at', 'Harvard', ',', 'and', 'is', 'a', 'great', 'guy', '.']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!