wrapops¶
This module gathers text operations that are wrapped from standard python functions
resub¶
- class
textops.
resub
(string, count=0, flags=0)¶Substitute a regular expression within a string or a list of strings
It uses
re.sub()
to replace the input text.
Parameters: Returns: The replaced text
Return type: str or list
Examples
>>> 'Words, words, words.' | resub('[Ww]ords','Mots') 'Mots, Mots, Mots.' >>> ['Words1 words2', 'words', 'words.' ] >> resub('[Ww]ords','Mots',1) ['Mots1 words2', 'Mots', 'Mots.']