title: Regex to find variable names and their values in a text string
body: <p>Let's say I have a random variable and value in a text string (str). What regular expression do I have to write to return the variable's name and value in an array?</p>
  
  <pre><code>str="var abcde = 'xyz';"
  result = str.match(/.../); //&lt;-??
  //['abcde','xyz']; //value of result
  </code></pre>
  
  <p>I tried <code>/\bvar\s+([^;]+)/</code> but it will return the whole expression <code>abcde = 'xyz'</code> as a result.</p>
  
  <p>It is always in the format of <code>var somename = somevalue;</code> somevalue can be a number, a string, an array or an object. So it can contain () and {} and commas.</p>