<?php $re = "/\\b([0-9]+)(ml|kg|g|l)\\b/"; $str = "540ml"; preg_match($re, $str, $matches);print_r($matches);
Standard input is empty
Array ( [0] => 540ml [1] => 540 [2] => ml )
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!