These methods belong to Python RegEx ‘re’ module and are used to modify strings.
split(): This method is used to split a given string into a list.
sub(): This method is used to find a substring where a regex pattern matches, and then it replaces the matched substring with a different string.
subn(): This method is similar to the sub() method, but it returns the new string, along with the number of replacements.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.
We use cookies to ensure that we give you the best experience and use cookies in order to personalize the advertising that you see on our website. Read more about our Privacy Policy.Got it!