title: Python read and search String in a file
body: <p>I want to write a script to read apache.conf file and get "MaxClients" value, "Keepalive" value,"KeepAliveTimeout" value and "ServerLimit" value etc, to different arguments. But it should not be read if the line start with "#" value. I have written sample code as below, but it is not ignoring # value, Could someone help me to do this, I just need only the value. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import re
  
  #afile = open('apache.txt','r')
  #for aline in afile:
  #    aline1 = aline.rstrip()
  #    ax = re.findall('MaxClients ',aline1 )
  #    print(ax)
  
  with open('apache.txt','r') as afile:
      for line in afile:
          match = re.search('MaxClients ([^,]+)', line )
          if match:
              print(match.group(1))</code></pre>
  </div>
  </div>
  </p>