string.find for case insensitive search

Larry Bates larry.bates at websafe.com
Wed Feb 7 16:14:06 EST 2007


Johny wrote:
> Is there a good way how to use string.find function to find a
> substring if I need to you case insensitive substring?
> Thanks for reply
> LL
> 
Maybe something like:

x="my string I'm going to SEarCH"
hasword='SEARCH' in x.upper()
location=x.upper().find('SEARCH')

print hasword
True

print location
23


-Larry




More information about the Python-list mailing list