Case-insensitive string comparison

Avner Ben avner at skilldesign.com
Mon Apr 14 15:37:35 EDT 2003


"Alex Martelli" <aleax at aleax.it> wrote in message
news:Y%Dma.13754$LB6.370780 at news1.tin.it...
> Avner Ben wrote:
>
> > Question:
> >
> >     Does standard Python have case-insensitive string comparison and
> >     search?
>
> No.  You normally accomplish them either with regular expressions (which
> CAN be compiled into case-insensitive mode) or by coercing strings to
> one fixed case (e.g. with the .lower method of string objects).
>

    I have tried the lower them all approach, but at the rate of processing
I need, it has turned out to reduce application speed by a factor of four.
What I need is an efficient built-in way of doing this.

    I will try the regular expression approach and see if it meets my
performance criteria.

    If that does not help, I guess I will have to delegate the job to a C
routine.

        Avner.






More information about the Python-list mailing list