fork download
  1. <?php
  2.  
  3. $re = "/\\b([0-9]+)(ml|kg|g|l)\\b/";
  4. $str = "540ml";
  5.  
  6. preg_match($re, $str, $matches);
  7. print_r($matches);
Success #stdin #stdout 0.03s 52432KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 540ml
    [1] => 540
    [2] => ml
)