Примеры использования основных методов regexp
>>> s = 'This sample text=123 and test regexp=5, the end'
>>> re.findall(r'(\w+)=(\d+)',s)
[('text', '123'), ('regexp', '5')]
>>> s = '[email protected]'
>>> g = re.match(r'[\w\d.\-]+@[\w\d.\-]+',s)
>>> g.group(0)
'[email protected]'
>>> re.sub(r'\[(\d+)\]',r'+\1+','hello [123] world!')
'hello +123+ world!'
>>> s = 'hello world, this regexp'
>>> re.split(r'\W+',s)
['hello', 'world', 'this', 'regexp']
>>> re.split(r'\W+',s,1)
['hello', 'world, this regexp']
>>> re.split(r'(\W+)',s)
['hello', ' ', 'world', ', ', 'this', ' ', 'regexp']
>>> c = re.compile(r'(\w+)=(\d+)')
>>> s = 'This sample text=123 and test regexp=5, the end'
>>> c.findall(s)
[('text', '123'), ('regexp', '5')]