[Tutor] re Formating

Kent Johnson kent37 at tds.net
Wed Feb 25 14:38:55 CET 2009


On Wed, Feb 25, 2009 at 7:46 AM, prasad rao <prasadaraon50 at gmail.com> wrote:
> hi
>>>> licenseRe = re.compile(r'\(([A-Z]+)\)\s*(No.\d+)?')
>>>> for license in licenses:
>       m = licenseRe.search(license)
>       print m.group(1, 3)
>
> Traceback (most recent call last):
>   File "<pyshell#17>", line 3, in <module>
>     print m.group(1, 3)
> IndexError: no such group
> Something wrong with this code.

There are only two groups in the re, try
  print m.group(1, 2)

Kent


More information about the Tutor mailing list