AndrewN wrote:
d = re.compile(' \d{3}\.\d{3}\.\d{3} ')
d.findall(' 123.345.678 ')

[' 123.345.678 ']

Works for me.


Yes, you're correct. That works if there is a space at the front and back. However, place '123.345.678' in a file by itself and it doesn't work.


What I'm trying to avoid is something like this '1234.345.6789' Notice the 4 chars in the first and last part? findall gets '234.345.678' and returns positive... I thought that by requiring spaces I could avoid matches such as this, but I was wrong. How can I get what I'm looking for w/o getting the other stuff as well?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to