Need to cut out all characters in between 2 brackets in a string
<p>I have a string in python 2.7:</p>

<pre><code>a = 'This is some text ( - 1) - And some more text (0:0) - Some more Text'
</code></pre>

<p>I would like to use a regex to get the ' - 1' out of this string. </p>

<p>I've tried but can't find it, thanks for your help, I've tried: </p>

<pre><code>re.search(r'.*?\((.*)\).*', a)
</code></pre>

<p>But that didn't work. Mind you there's a second ( ) in the string but I only need the first one. </p>

<p>THANK YOU!</p>

<p>Below code will return all the match in string:</p>

<pre><code>&gt;&gt;&gt; import re
&gt;&gt;&gt; mystring = 'This is some text ( - 1) - And some more text (0:0) - Some more Text'
&gt;&gt;&gt; regex = re.compile(".*?\((.*?)\)")
&gt;&gt;&gt; result = re.findall(regex, mystring)
&gt;&gt;&gt; result
[' - 1', '0:0']
</code></pre>

<p>To get first (or whatever value you want), access it by corresponding index:</p>

<pre><code>&gt;&gt;&gt; result[0]
'-1'
</code></pre>

python regex