On 2005-07-26, Duncan Booth <[EMAIL PROTECTED]> wrote: >>>> rx1=re.compile(r"""\b\d{4}(?:-\d{4})?,""") >>>> rx1.findall("1234,2222-8888,4567,") > ['1234,', '2222-8888,', '4567,']
Thanks all for good advice. However this last expression also matches the first four digits when the input is more than four digits. To resolve this problem, I first do a match of this, regex=re.compile(r"""\A(\b\d{4},|\d{4}-\d{4},)*(\b\d{4}|\d{4}-\d{4})\Z""") If this turns out ok, I do a find all with your expression, and then I get the desired result. -- Har du et kjøleskap, har du en TV så har du alt du trenger for å leve -Jokke & Valentinerne -- http://mail.python.org/mailman/listinfo/python-list