[BangPypers] Question on Pattern Matching and Regular Expression

Gora Mohanty gora at mimirtech.com
Mon Jan 7 11:10:01 CET 2013


On 7 January 2013 15:38, Gora Mohanty <gora at mimirtech.com> wrote:

> import re
> TITLE_RE = re.compile( r'#\n#([^\n]*)\n#\n \n\[([^\]]*)\]\n \n',
> re.MULTILINE|re.DOTALL )
> for m in TITLE_RE.finditer( s.strip ):
>      title, info = m.groups()
>      print title, info

Oops, that should be s.strip(), viz.,
import re
TITLE_RE = re.compile( r'#\n#([^\n]*)\n#\n \n\[([^\]]*)\]\n \n',
re.MULTILINE|re.DOTALL )
for m in TITLE_RE.finditer( s.strip() ):
      title, info = m.groups()
      print title, info

Regards,
Gora


More information about the BangPypers mailing list