Python Regex and group function
<p>Hi trying to separate each of the expressions from the colon.  So want to obtain 'ss_vv', 'kk' and 'pp'.  But the two print expressions below give me 'v' and 'k', so getting parts only of each string.  Can anyone see what wrong here?       </p>

<pre><code>m0 = re.compile(r'([a-z]|_)+:([a-z]|_)+:([a-z]|_)+')
m1 = m0.search('ss_vv:kk:pp')
print m1.group(1)
print m1.group(2)
</code></pre>

<pre><code>In [52]: m0 = re.compile(r'([a-z|_]+):([a-z|_]+):([a-z|_]+)')

In [53]: m1 = m0.search('ss_vv:kk:pp')

In [54]: print m1.group(1)
ss_vv

In [55]: print m1.group(2)
kk

In [56]: print m1.group(3)
pp
</code></pre>

<p>What my regex does:</p>

<pre><code>([a-z|_]+):([a-z|_]+):([a-z|_]+)
</code></pre>

<p><img src="https://www.debuggex.com/i/GLOmQniLEruFOdRF.png" alt="Regular expression visualization"></p>

<p><a href="https://www.debuggex.com/r/GLOmQniLEruFOdRF" rel="nofollow">Debuggex Demo</a></p>

<p>What your regex does:</p>

<pre><code>([a-z]|_)+:([a-z]|_)+:([a-z]|_)+
</code></pre>

<p><img src="https://www.debuggex.com/i/RMei9CVdMLW4aEkE.png" alt="Regular expression visualization"></p>

<p><a href="https://www.debuggex.com/r/RMei9CVdMLW4aEkE" rel="nofollow">Debuggex Demo</a></p>

python regex