On Jul 21, 11:04 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> The drawback is that it's a lot easier to mess up the edge cases if you
> do that (as this thread has shown). The small speedup you get in
> typical cases is quickly offset by extra debugging/testing time (or, for
> that matter, argui
oj wrote:
Fine, this works, although match instead of search blah blah blah as
has already been mentioned. I still think searching for one invalid
character is more elegant then trying to match the entire string, but
that's just personal preference, I guess.
The drawback is that it's a lot eas
On Jul 19, 3:04 am, Andrew Freeman <[EMAIL PROTECTED]> wrote:
> let me revise it please:
>
> To show if valid:
>
> if re.search(r'^[LRM]*$', 'LM'):
> print 'Valid'
Fine, this works, although match instead of search blah blah blah as
has already been mentioned. I still think searching for one i
John Machin wrote:
On Jul 20, 11:14 am, Andrew Freeman <[EMAIL PROTECTED]> wrote:
John Machin wrote:
(4) I highly doubt that this code was actually to be used in an
interactive session,
The offending code is a nonsense wherever it is used.
the False/True output was trun
On Jul 20, 11:14 am, Andrew Freeman <[EMAIL PROTECTED]> wrote:
> John Machin wrote:
> (4) I highly doubt that this code was actually to be used in an
> interactive session,
The offending code is a nonsense wherever it is used.
> the False/True output was truncated intentionally,
What meaning ar
John Machin wrote:
On Jul 20, 5:00 am, Andrew Freeman <[EMAIL PROTECTED]> wrote:
Andrew Freeman wrote:
John Machin wrote:
A couple of points:
(1) Instead of search(r'^blahblah', ...) use match(r'blahblah', ...)
(2) You need to choose your end-anchor correctly; your pattern is
pe
On Jul 20, 5:00 am, Andrew Freeman <[EMAIL PROTECTED]> wrote:
> Andrew Freeman wrote:
> > John Machin wrote:
> >> A couple of points:
> >> (1) Instead of search(r'^blahblah', ...) use match(r'blahblah', ...)
> >> (2) You need to choose your end-anchor correctly; your pattern is
> >> permitting a ne
Andrew Freeman wrote:
John Machin wrote:
A couple of points:
(1) Instead of search(r'^blahblah', ...) use match(r'blahblah', ...)
(2) You need to choose your end-anchor correctly; your pattern is
permitting a newline at the end:
I forgot to change search to match. This should be better:
def ma
John Machin wrote:
On Jul 19, 12:04 pm, Andrew Freeman <[EMAIL PROTECTED]> wrote:
To show if valid:
if re.search(r'^[LRM]*$', 'LM'):
print 'Valid'
A couple of points:
(1) Instead of search(r'^blahblah', ...) use match(r'blahblah', ...)
(2) You need to choose your end-anchor corre
On Jul 19, 12:04 pm, Andrew Freeman <[EMAIL PROTECTED]> wrote:
> To show if valid:
>
> if re.search(r'^[LRM]*$', 'LM'):
> print 'Valid'
>
A couple of points:
(1) Instead of search(r'^blahblah', ...) use match(r'blahblah', ...)
(2) You need to choose your end-anchor correctly; your pattern is
p
oj wrote:
Why not just use * instead of + like:
if re.search(r'^[^LRM]*$', var): # note: ^ outside [] is start of
string; $ means end of string
print "Invalid"
This will *only* print invalid when there is a character other than L,
R, or M or a empty string.
Sorry, forge
>
> > Why not just use * instead of + like:
>
> > if re.search(r'^[^LRM]*$', var): # note: ^ outside [] is start of
> > string; $ means end of string
> > print "Invalid"
>
> > This will *only* print invalid when there is a character other than L,
> > R, or M or a empty string.
>
> Sorry, forget
On Jul 18, 7:51 am, Andrew Freeman <[EMAIL PROTECTED]> wrote:
> Andrew Freeman wrote:
> > oj wrote:
> >> On Jul 18, 12:10 pm, John Machin <[EMAIL PROTECTED]> wrote:
>
> >>> On Jul 18, 9:05 pm, oj <[EMAIL PROTECTED]> wrote:
>
> On Jul 18, 11:33 am, [EMAIL PROTECTED] wrote:
>
> > Hi,
> >
On Jul 18, 7:51 pm, Andrew Freeman <[EMAIL PROTECTED]> wrote:
> Andrew Freeman wrote:
> > oj wrote:
> >> On Jul 18, 12:10 pm, John Machin <[EMAIL PROTECTED]> wrote:
>
> >>> On Jul 18, 9:05 pm, oj <[EMAIL PROTECTED]> wrote:
>
> On Jul 18, 11:33 am, [EMAIL PROTECTED] wrote:
>
> > Hi,
> >
Andrew Freeman wrote:
oj wrote:
On Jul 18, 12:10 pm, John Machin <[EMAIL PROTECTED]> wrote:
On Jul 18, 9:05 pm, oj <[EMAIL PROTECTED]> wrote:
On Jul 18, 11:33 am, [EMAIL PROTECTED] wrote:
Hi,
Hi,
I am taking a string as an input from the user and it
should only
oj wrote:
On Jul 18, 12:10 pm, John Machin <[EMAIL PROTECTED]> wrote:
On Jul 18, 9:05 pm, oj <[EMAIL PROTECTED]> wrote:
On Jul 18, 11:33 am, [EMAIL PROTECTED] wrote:
Hi,
Hi,
I am taking a string as an input from the user and it should only
contain the chars
[EMAIL PROTECTED] wrote:
I am taking a string as an input from the user and it should only
contain the chars:L , M or R
How about skipping re's and doing something like:
set(input_string) <= set('LMR')
If you want to disallow the empty string:
set([]) < set(input_string) <= set('LMR')
--S
On Jul 18, 12:10 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Jul 18, 9:05 pm, oj <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jul 18, 11:33 am, [EMAIL PROTECTED] wrote:
>
> > > Hi,
>
> > > Hi,
>
> > > I am taking a string as an input from the user and it should only
> > > contain the chars:L , M or
On Jul 18, 9:05 pm, oj <[EMAIL PROTECTED]> wrote:
> On Jul 18, 11:33 am, [EMAIL PROTECTED] wrote:
>
>
>
> > Hi,
>
> > Hi,
>
> > 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:
>
On Jul 18, 11:33 am, [EMAIL PROTECTED] wrote:
> Hi,
>
> Hi,
>
> 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
On Jul 18, 3:46 pm, [EMAIL PROTECTED] (Eddie Corns) wrote:
> [EMAIL PROTECTED] writes:
> >Hi,
> >Hi,
> >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
On Jul 18, 8:33 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> Hi,
>
> 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
[EMAIL PROTECTED] writes:
>Hi,
>Hi,
>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.
Hi,
Hi,
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 LRLRL
Hi,
Hi,
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 LRLRL
25 matches
Mail list logo