[Tutor] REGEX EXPLANATION

delegbede at dudupay.com delegbede at dudupay.com
Tue Dec 21 16:10:19 CET 2010


I have been reading regex in order to work around an assignment. 

Could anyone explain to me in plain english what the following regex expression translate to. 

(r'PSC(?P<observer_id>\d{6})(DC|VR)(\d{2})(RC|GA)(\d{3})(!?([A-Z\d]{1,})@?(.*))?', re.I)

(r'PSC(?P<observer_id>\d{6})VR(?P<day>\d{2})RC(?P<location_id>\d{3})(?P<responses>[ABCDEFGHJKMNPQRSTUVWXYZ\d]{2,})?', re.I)

(r'PSC(?P<observer_id>\d{6})VR(?P<day>\d{2})(?P<location_type>(RC|GA))(?P<location_id>\d{3})!(?P<responses>[ABCDEFGHJKMNPQ]{1,})@?(?P<comment>.*)', re.I)

(r'PSC(?P<observer_id>\d{6})DC(?P<day>\d{2})RC(?P<location_id>\d{3})(?P<responses>[ABCDEFGHJKMNPQRSTUVWX\d]{2,})?', re.I)

(r'PSC(?P<observer_id>\d{6})DC(?P<day>\d{2})(?P<location_type>(RC|GA))(?P<location_id>\d{3})!(?P<responses>[ABCDEFGHJK]{1,})@?(?P<comment>.*)', re.I)

Like reading it out in plain english. This should further help me understand how these signs work and then I can get along. 

Thanks. 
Sent from my BlackBerry wireless device from MTN


More information about the Tutor mailing list