Magnus Lycka wrote: > I want an re that matches strings like "21MAR06 31APR06 1236", > where the last part is day numbers (1-7), i.e it can contain > the numbers 1-7, in order, only one of each, and at least one > digit. I want it as three groups. I was thinking of > > r"(\d\d[A-Z]\d\d) (\d\d[A-Z]\d\d) (1?2?3?4?5?6?7?)" > > but that will match even if the third group is empty, > right? Does anyone have good and not overly complex RE for > this?
how about (untested) r"(\d\d[A-Z]{3}\d\d) (\d\d[A-Z]{3}\d\d) (?=[1234567])(1?2?3?4?5?6?7?)" where {3} means require three copies of the previous RE part, and (?=[1234567]) means require at least one of 1-7, but don't move forward if it matches. </F> -- http://mail.python.org/mailman/listinfo/python-list