python regex to split list entry's name into list name and index
<p>How can I use regular expressions to parse <code>&lt;listname&gt;[#]</code> into <code>[listname, #]</code>?</p>

<p>Here's what I've tried:</p>

<pre><code>&gt; s = 'li[10]'
&gt; re.split(s,r'[%d]')
['[%d]']
&gt; re.findall(s,r'[%d]')
[]
&gt; s.split(r'[%d]')
['li[0]']
</code></pre>

<p>the desired output is <code>li</code> and <code>10</code></p>

<p>How about <code>(.*)\[(.*)\]</code>?</p>

<pre><code>re.findall("(.*)\[(.*)\]", s)

# [('li', '10')]
</code></pre>

python regex