how to express the following regular expression?

Stephen fungho at sinaman.com
Wed Nov 21 21:31:51 EST 2001


Thank you very much!

"Carl Howells" <chowells at cs.uoregon.edu> wrote in message news:<9tft7a$30$1 at helix.cs.uoregon.edu>...
> "Stephen" <fungho at sinaman.com> wrote...
> > I want to search the following formats:
> >
> > ([1234567890]*)R
> > or
> > P([1234567890]*)
> >
> > this means there must be a 'P' before the number or a 'R' after the
> > number. However, I think I can't use this:
> > P?([1234567890]*)R?
> > because the number without P and R is also matched!
> >
> > How can I express it?
> 
> Exactly you you'd expect...  One or the other:
> 
> (P\d*)|(\d*R)
> 
> You could also use [0-9] in place of \d, if you were really set on using the
> [] notation.  But there's no reason to use [1234567890].



More information about the Python-list mailing list