concept re module in category python
appears as: re module, The re module

This is an excerpt from Manning's book Tiny Python Projects: Learn coding and testing with puzzles and games.
Regular expressions provide a syntax for describing patterns of text with the remodule. There.sub()method will substitute found patterns with new text. The original text will be unchanged.
The
remodule has a function calledre.split()that works similarly. I recommend you readhelp(re.split), as this is a very powerful and flexible function. Likere.match(), which we used in chapter 14, this function wants at least apatternand astring. We can usere.split()with a comma to get the same output asstr.split(), and, as before, the commas are missing from the result: