title: PHP Regex on measures
body: <p>I have some strings and i would like to get the amount and the unit. Here is an example of the string and the like wanted array :</p>
  
  <ul>
  <li>10 bags -> ["10","bags"]</li>
  <li>10 lbs -> ["10","lbs"]</li>
  <li>10 lbs of oak wood ["10", "lbs"] (i don't need the last part)</li>
  <li>10 g ["10", "g"]</li>
  <li>10 lbs of wood + 8 planks + 1 screw ["10", "lbs", "8", "1"]</li>
  </ul>
  
  <p>Have you any idea ? I have a very large amount of "last part that i don't need" so i wouldn't use the str_replace function. Currently i try to find something to use with preg_match. I found something like this but i'm not good with regex to understand how to add the "+" handle and to avoid it match "10 g" on string like "10 grapes".</p>
  
  <pre><code>'/(\d*\.?\d+)\s*(lbs?|g|kgs?|pounds?|oz|ounces?|g|mg|ml)\b/'
  </code></pre>