Why is Python re.sub capture not zero indexed? : <p>When capturing <code>Boiler</code> and <code>1</code> shown below, they are then referenced as \1 and \2. This took me a while to figure out why this was not working as I expected the capture group to be zero indexed. Why is the capture group not zero indexed unlike nearly everything in Python?</p>

<pre><code>string = "BoilerRoom_Boiler_Booster_On"
re.sub('(Boiler)_(\d)', r'\1-\2', string)

Out[21]:
'BoilerRoom_Boiler-1_Booster_On'
</code></pre>
