title: How to extract values from a string in javascript?
body: <p>I need some help with extracting values from a cookie using javascript.</p>
  
  <p>The string in a cookie looks something like this:</p>
  
  <pre><code>string = 'id=1||price=500||name=Item name||shipping=0||quantity=2++id=2||price=1500||name=Some other name||shipping=10||quantity=2'
  </code></pre>
  
  <p>By using string.split() and string.replace() and a some ugly looking code I've somehow managed to get the values i need (price, name, shipping, quantity). But the problem is that sometimes not all of the strings in the cookie are the same. Sometimes the sting in a cookie will look something like this :</p>
  
  <pre><code>   string = 'id=c1||color=red||size=XL||price=500||name=Item name||shipping=0||quantity=2++id=c1||price=500||name=Item name||shipping=0||quantity=2'
  </code></pre>
  
  <p>with some items having color and size as parameters and sometimes only one of those.</p>
  
  <p>Is there some more efficient way to explain to my computer that i want the part of the string after 'price=' to be a variable named 'price' etc. </p>
  
  <p>I hope I'm making sense I've tried to be as precise as I could.</p>
  
  <p>Anyway, thank you for any help</p>
  
  <p>EDIT: I just wanted to say thanks to all the great people of StackOverflow for such wonderfull ideas. Because of all of your great suggestions I'm going out to get drunk tonight. Thank you all :)</p>