How to match an underscore using Python's regex?
<p>I'm having trouble matching the underscore character in Python using regular expressions. Just playing around in the shell, I get:</p>

<pre><code>&gt;&gt;&gt; import re
&gt;&gt;&gt; re.match(r'a', 'abc')
&lt;_sre.SRE_Match object at 0xb746a368&gt;
&gt;&gt;&gt; re.match(r'_', 'ab_c')
&gt;&gt;&gt; re.match(r'[_]', 'ab_c')
&gt;&gt;&gt; re.match(r'\_', 'ab_c')
</code></pre>

<p>I would have expected at least one of these to return a match object. Am I doing something wrong?</p>