i'm trying to get something working that will pull whole numbers, proper and improper fractions, mixed numbers, and decimals from a string.
here is as far as I've been able to get with my feeble regex skills:
$str = '54.75 This string 3 contains .25 several 5 3/4 types of 0.689 numbers 12/5';
preg_match_all("#[0-9]*[\.| ]?([0-9]*)[\/]?[0-9]*#", $str, $matches);
foreach ($matches[0] as $m) {
echo ($m != '' && $m != ' ') ? $m . '<br />' : '';
}
except this outputs the following:
54.75
3
.25
5
3/4
.689
12/5
...close, but not quite what i'm looking for.
can anyone help?
thanks