Explain split(), sub(), subn() methods of “re” module in Python.
split()
, sub()
, and subn()
Methods of the re
Module:
split()
: Splits a string into a list of substrings based on a regular expression pattern.sub()
: Replaces occurrences of a pattern in a string with a specified replacement.subn()
: Similar to sub()
, but also returns the number of substitutions made.