Python 2.7, i want to get values between = and , in a string without using multiple split.
<p>Ex: "name=sam,city=london, age=24,location=abc"
I want to get sam, london, 24 and abc in seperate variables. 
Without using split because it results in many useless variables. 
Will regular expression help?
Note: The last value will not have  , 
In this case no ,  after abc. 
Thank you</p>

<p>What's the useless info obtained with split?</p>

<pre><code>In [365]: a = "name=sam,city=london, age=24,location=abc"

In [366]: [x.split('=')[1] for x in a.split(',')]
Out[366]: ['sam', 'london', '24', 'abc']
</code></pre>

<p>Using regex:</p>

<pre><code>In [368]: [x[1] for x in re.findall(r'(\w+=(\w+))', a)]
Out[368]: ['sam', 'london', '24', 'abc']
</code></pre>

<p>Explanation for regex:</p>

<pre><code>(\w+=(\w+))
</code></pre>

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

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

python