[Tutor] Re: Searching for text while ignoring case
Emile van Sebille
emile@fenx.com
Tue Apr 1 13:59:02 2003
jlohman@cox.net asks,
> How do I make a command like FIND() search for text
> strings in a line and can recognize them regardless
> of case? A word like "puppy" would be "Puppy" sometimes
> if it started a sentence. However, a search for "puppy"
> will miss "Puppy".
>
Here's one way:
>>> text = "Testing, one, two, three, testing."
>>> text.find("testing")
26
>>> text.upper().find("testing".upper())
0
>>>
(Remember that -1 indicates no match with find)
--
Emile van Sebille
emile@fenx.com
---------