Differentiate between split(), sub(), and subn() methods of the re module?
Did you read the documentation?
If so, what don’t you understand?
The re module is what we have for processing regular expressions with Python. Let’s talk about the three methods we mentioned-
- split()- This makes use of a regex pattern to split a string into a list
- sub()- This looks for all substrings where the regex pattern matches, and replaces them with a different string
- subn()- Like sub(), this returns the new string and the number of replacements made