regex doubts

Fredrik Lundh fredrik at pythonware.com
Sat Jul 19 15:04:06 EDT 2008


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).

</F>




More information about the Python-list mailing list