string is "Lorem, ipsum 12 dolorem, si amet 58,14" and etc. I need to extract "12" and "58,14". I have no experience with regular expresions. So the question is - how should I do this? :) Language (if this matters) is php5.
<?php
$foundMatches = array();
$targetString = "Lorem, ipsum 12 dolorem, si amet 58,14";
preg_match_all('/([1-9]\d*|0)(,\d+)?/', $targetString, $foundMatches);
var_dump($foundMatches);
?>
You'll find the needed results at $foundMatches[0]
.
Edit: Updated regex to not match 123,
or 012
. If you want those use the older /\d+,?\d*?/
.
Useful reading: http://www.regular-expressions.info/