-1

I already know about the lower() and upper() but is there any simplest method to do it,for example like ignoreCase() in Java,

ex code: a="hello how are you,i am praveen",

now if i do "PRAVEEN" in a:

it gives us false,i want to make it caseinsensitive thank you in advance

praveen JP
  • 9
  • 2
  • 10
  • What list? please create an [mcve]. – Sayse Jan 24 '17 at 07:49
  • now see the example what i given and please help me – praveen JP Jan 24 '17 at 07:51
  • Have you tried copying your question title into google?... – Sayse Jan 24 '17 at 07:52
  • ya,but it showing only lower() and upper() so i am here – praveen JP Jan 24 '17 at 07:53
  • This task is only simple if the strings are plain ASCII (or Latin1). If you need to handle arbitrary Unicode then you need to be careful, as the top answers at the suggested duplicate question show. FWIW, the `re` module can do case-insensitive comparisons & searches using the `re.IGNORECASE` flag, but it's not safe to use on arbitrary Unicode. – PM 2Ring Jan 24 '17 at 08:10

1 Answers1

0

I could be missing something but I think the simplest solution is just to use the lower() function.

s = "PRAVEEN"
a = "hello how are you,i am praveen"

# will return true if s in a (regardless of original upper/lower cases)
if s.lower() in a.lower():
    print "s in a"

You could write a function for it if you have to do it many times?

def isInString(substring, originalString):
    if substring.lower() in originalString.lower():
        return true
    else:
        return false
RichSmith
  • 900
  • 5
  • 11