Re: A better RE?

2006-03-10 Thread Magnus Lycka
Fredrik Lundh wrote: > Magnus Lycka wrote: > r"(\d\d[A-Z]{3}\d\d) (\d\d[A-Z]{3}\d\d) (?=[1234567])(1?2?3?4?5?6?7?)" > Thanks a lot. (I knew about {3} of course, I was in a hurry when I posted since I was close to missing my train...) -- http://mail.python.org/mailman/listinfo/python-list

Re: A better RE?

2006-03-10 Thread Magnus Lycka
Schüle Daniel wrote: > >>> txt = "21MAR06 31APR06 1236" > > >>> m = '(?:JAN|FEB|MAR|APR|MAI|JUN|JUL|AUG|SEP|OCT|NOV|DEZ)' > # non capturing group (:?) > > >>> p = re.compile(r"(\d\d%s\d\d) (\d\d%s\d\d) > (?=[1234567])(1?2?3?4?5?6?7?)" % (m,m)) > > >>> p.match(txt).group(1) > '21MAR06' > >

Re: A better RE?

2006-03-10 Thread Paul McGuire
"Magnus Lycka" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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 grou

Re: A better RE?

2006-03-10 Thread Eddie Corns
"Jim" <[EMAIL PROTECTED]> writes: >Eddie Corns wrote: >> Just a small point - what does "in order" mean here? if it means that eg 1362 >> is not valid then you're stuck because it's context sensitive and hence not >> regular. >I'm not seeing that. Any finite language is regular -- as a last >res

Re: A better RE?

2006-03-10 Thread Eddie Corns
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: >Eddie Corns 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 grou

Re: A better RE?

2006-03-10 Thread Jim
Eddie Corns wrote: > Just a small point - what does "in order" mean here? if it means that eg 1362 > is not valid then you're stuck because it's context sensitive and hence not > regular. I'm not seeing that. Any finite language is regular -- as a last resort you could list all ascending sequence

Re: A better RE?

2006-03-10 Thread Fredrik Lundh
Eddie Corns 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 > > Just a small point - wha

Re: A better RE?

2006-03-10 Thread Eddie Corns
Magnus Lycka <[EMAIL PROTECTED]> writes: >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 Just a small p

Re: A better RE?

2006-03-10 Thread bruno at modulix
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]

Re: A better RE?

2006-03-09 Thread Schüle Daniel
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]

Re: A better RE?

2006-03-09 Thread Fredrik Lundh
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]

A better RE?

2006-03-09 Thread Magnus Lycka
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 tha