sjmachin at lexicon.net
Sat Jul 19 23:44:24 CEST 2008
On Jul 20, 6:35 am, MRAB <goo... at mrabarnett.plus.com> wrote:
> On Jul 19, 9:12 pm, John Machin <sjmac... at lexicon.net> wrote:
> > On Jul 20, 5:04 am, Fredrik Lundh <fred... at pythonware.com> wrote:
> > > Mr SZ wrote:
> > > > I am taking a string as an input from the user and it should only
> > > > contain the chars:L , M or R
> > > > I tried the folllowing in kodos but they are still not perfect:
> > > > [^A-K,^N-Q,^S-Z,^0-9]
> > > > [L][M][R]
> > > > [LRM]?L?[LRM]? etc but they do not exactly meet what I need.
> > > > For eg: LRLRLRLRLM is ok but LRLRLRNL is not as it has 'N' .like that.
> > > try "[LRM]+$" (an L or an R or an M, one or more times, all the way to
> > > the end of the string).
> > Ummm ... with the default flag settings, shouldn't that be \Z instead
> > of $
> > ?
> $ means end of string unless the multiline flag is used, in which case
> it means end of line.
What manual are you quoting that from? What version of Python are you
using? Can you demonstrate that the pattern "[LRM]+$" will fail to
match the string "L\n"?
More information about the Python-list