[Tutor] Formatting

prasad rao prasadaraon50 at gmail.com
Wed Feb 25 06:07:25 CET 2009


hi.

s = 'Association of British Travel Agents (ABTA) No.56542\nAir Travel
Organisation Licence (ATOL)\nAppointed Agents ofIATA (IATA)\nIncentive
Travel & Meet. Association (ITMA)'


licenses = re.split("\n+", s)

licenseRe = re.compile(r'\(([A-Z]+)\)( No. (\d+))?')


>>> for license in licenses:
       m = licenseRe.search(license)
       print m.group(1, 3)


('ABTA', None)
('ATOL', None)
('IATA', None)
('ITMA', None)

The no 56542 is not getting into  m.group()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090225/7e94f6e9/attachment.htm>


More information about the Tutor mailing list