title: Case sensitive match using python re.search
body: <p>I want to do a case sensitive match from the text. In the below case i tried matching the "Ca.iNy" using re.search, I want to match where "C" should be in upper case and rest all characters might be in any of the cases. If it matches the case i want set a value to a variable.</p>
  
  <p>I have taken the help form SO and implemented by checking whether the first letter is a capital or not and it worked fine for a single check. </p>
  
  <pre><code>s = "The details belong to (Ca.iNy.) in this case"
  reg = re.compile("Ca.iny.", re.I)
  reg.search(s).group().startswith("C").
  </code></pre>
  
  <p>However, I am not able to use it in an "if else loop". I tried the code below, but the search seems to be case-insensitive. Can anyone please let me?</p>
  
  <pre><code>import re
  
  st = "The details belong to (Ca.iNy.) in this case"
  Mval = ''
  
  if re.search(r"C(?i)a.iny", st):
      Mval = "AAAAA"
  elif re.search(r"(?i)Ky.", st):
      Mval = "BBBBB"
  elif re.search(r"(?i)M.sa.", st):
      Mval = "CCCCC"
  else:
      Mval = "DDDDD"
  
  print Mval
  </code></pre>