What base of difference do split(), sub(), and subn() methods of the re module follows

What base of difference do split(), sub(), and subn() methods of the re module follows
0

#1

Differentiate between split(), sub(), and subn() methods of the re module?


#2

Did you read the documentation?
If so, what don’t you understand?
https://docs.python.org/3/library/re.html?highlight=sub#re.sub


#3

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