The data structure string is modified with the help of the "re" module in python. In the module, three methods are used. When for modification regex pattern is used to split a given string into a list spilt() is used.
When the method finds all the substrings where the regex pattern matches and then replace them with a different string, the sub() command is used.
The command subn() is similar to sub() and also returns the new string along with the number of replacements.