Jacob S. wrote:
Dive into Python, an excellent tutorial has a case study on this very same topic.

The biggest problem that nobody has mentioned yet is the fact that group() will not have anything unless you explicitly tell it to group it.

group() defaults to returning group 0 which is the whole match.

 >>> import re
 >>> string = 'My phone is 410-995-1155'
 >>> pattern = r'\d{3}-\d{3}-\d{4}'
 >>> re.search(pattern,string).group()
'410-995-1155'

Kent

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

Reply via email to