title: unbalanced parenthesis error with python regex
body: <p>I have a python scripts which retrives the data from a log file using the regex, while running the script i am getting an error <code>sre_constants.error: unbalanced parenthesis</code>.</p>
  
  <p>Below is the script where i'm trying to user regex.</p>
  
  <pre><code>#!/grid/common/pkgs/python/v2.7.10/bin/python
  import sys
  import re
  var1 = ''
  var2 = ''
  Html_file= open("/home/karn/healthCheck_result.html","w")
  html_str = """
  &lt;table border=1&gt;
       &lt;tr&gt;
         &lt;th bgcolor=fe9a2e&gt;Hostname&lt;/th&gt;
         &lt;th bgcolor=fe9a2e&gt;Service&lt;/th&gt;
       &lt;/tr&gt;
  """
  Html_file.write(html_str)
  fh=open(sys.argv[1],"r")
  for line in fh:
          pat_match=re.match("^\s+\HostName:\s+(.*?)\.*", line)
          pat_match1=re.match("^\s+(.*?\)Service Status:\s+(.*Not.*?)\.*", line)
          if pat_match:
                  Html_file.write("""&lt;TR&gt;&lt;TD bgcolor=fe9a2e&gt;""" + pat_match.group(1) + """&lt;/TD&gt;\n""")
          elif pat_match1:
                  Html_file.write("""&lt;TR&gt;&lt;TD&gt;&lt;TD&gt;""" + pat_match1.group(2) + """&lt;/TD&gt;&lt;/TD&gt;&lt;/TR&gt;\n""")
  </code></pre>
  
  <blockquote>
    <p>My log file has the below sample data: Where i'm searching the "Not" String and if it gets that then print that entire line Starting with <code>Service Status</code>.</p>
  </blockquote>
  
  <pre><code>[analytics1] sudo: /hm/it_script/DC/scripts/mainRun.py
  [analytics1] out: sudo password:
  [analytics1] out: HostName: analytics1
  [analytics1] out: Service Status:  NTP Service is Running On the host analytics1
  [analytics1] out: Service Status:  NSCD Service is Not Running On the host analytics1
  [analytics1] out: Service Status:  Sendmail Service is Running On the host analytics1
  [analytics1] out: Service Status:  Altris Service is Running On the host analytics1
  [analytics1] out: Service Status:  Automount Service is Running On the host analytics1
  [analytics1] out: Service Status:  Filesystem For Root(/) is more than 90% On the Host analytics1
  [analytics1] out: Service Status:  Filesystem For /var is more than 90% On the Host analytics1
  </code></pre>
  
  <p>Could you please advise whats wrong here..</p>