Regex in python for positive and negative integer
<p>I am new to learning regex in python and I'm wondering how do I use regex in python to store the integers(positive and negative) i want into a list!</p>

<p>For example</p>

<p>This is the data in a list.</p>

<pre><code>data =
    [u'\x1b[0m[\x1b[1m\x1b[0m\xbb\x1b[0m\x1b[36m]\x1b[0m (A=-5,B=5)', 

    u'\x1b[0m[\x1b[1m\x1b[0m\xbb\x1b[0m\x1b[36m]\x1b[0m (A=5,Y=5)', 

    u'\x1b[0m[\x1b[1m\x1b[10m\xbb\x1b[0m\x1b[36m]\x1b[0m : ']
</code></pre>

<p>How do I extract the integer values of A and B (negative and positive) and store them in a variable so that I can work with the numbers?</p>

<p>I tried smth like this but the list is empty .. </p>

<pre><code>for line in data[0]: 
        pattern = re.compile("([A-Z]=(-?\d+?),[A-Z]=(-?\d+?))") 
        store = pattern.findall(line)

print store
</code></pre>

<p>Thank you and appreciate it </p>

<p>For a positive and negative integer, with or without commas in between use: <code>-?(?:\d+,?)+</code></p>

<p><code>-?</code> with or without negative sign<br>
<code>(?:</code> opens a group<br>
<code>\d+</code> one or more digits<br>
<code>,?</code> optional comma<br>
<code>)</code> closes the group<br>
<code>(?:\d+,?)+</code> this group may have one or then one occencences</p>

python regex