title: Regex to match double underscores?
body: <p>I'm trying to extend the <code>python.lang</code> file so that it will make methods like <code>__init__</code> highlighted. I've been trying to come up with a Regex that will match all <code>__privateMethods()</code>.</p>
  
  <p>The <code>python.lang</code> is a XML file containing all of the highlighting rules for python files. Ex:</p>
  
  <pre><code>&lt;context id="special-variables" style-ref="special-variable"&gt;
     &lt;prefix&gt;(?&amp;lt;![\w\.])&lt;/prefix&gt;
     &lt;keyword&gt;self&lt;/keyword&gt;
     &lt;keyword&gt;__name__&lt;/keyword&gt;
     &lt;keyword&gt;__debug__&lt;/keyword&gt;
  &lt;/context&gt;
  </code></pre>
  
  <p>How can I extend this so that it matches double underscores? </p>
  
  <hr>
  
  <p><strong>[SOLUTION]:</strong> What I added to my <code>python.lang</code> file (if anyone's interested):</p>
  
  <p>First off you need to add this line near the top where the styles are defined.</p>
  
  <pre><code>&lt;style id="private-methods" _name="Private Methods" map-to="def:special-constant"/&gt;
  </code></pre>
  
  <p>Then you'll add the Regex that <a href="https://stackoverflow.com/questions/4902509/regex-to-match-double-underscores/4902883#4902883">Carles provided in his answer</a>:</p>
  
  <pre><code>&lt;context id="private-methods" style-ref="private-methods"&gt;
      &lt;match&gt;(__[a-zA-Z_]*(__)?)&lt;/match&gt;
  &lt;/context&gt;
  </code></pre>
  
  <p>And here is what it looks like when your done!</p>
  
  <p><img src="https://i.stack.imgur.com/q1jGv.png" alt="enter image description here"></p>