[Tutor] re module / separator

Serdar Tumgoren zstumgoren at gmail.com
Wed Jun 24 21:15:10 CEST 2009


apologies -- I just reread your post and appears you also want to
capture the dot after each "b" ( "b." )

In that case, you need to update the pattern to match for the dot. But
because the dot is itself a metacharacter, you have to escape it with
a backslash:

In [23]: re.findall(r'a\w+b\.',text)
Out[23]: ['a2345b.', 'a45453b.', 'a325643b.', 'a435643b.']

Again, all of these features are explained nicely at
http://www.amk.ca/python/howto/regex/


More information about the Tutor mailing list