One of the exercises in Core Python Programming is to
create a regular expression that will match a street
address.  Here is one of my attempts.

>>> street =  "1180 Bordeaux Drive"
>>> patt = "\d+ \w+"
>>> import re
>>> m = re.match(patt, street)
>>> if m is not None: m.group()
...
'1180 Bordeaux'
>>>

Obviously, I can just create a pattern "\d+ \w+ \w+". 
However, the pattern would be useless if I had a
street name like 3120 De la Cruz Boulevard.  Any
hints?

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to