interclubs
asked on
Help with Regex
I have the following regular expression, which I am trying to use to extract dollar amounts. I want it to only pull out values that either have a decimal point followed by 2 digits, or a dollar sign.
So in the below example, these would not be a match: #2343434 222 123-2333 $12.0
So in the below example, these would not be a match: #2343434 222 123-2333 $12.0
<?php
$text = '#2343434 222 123-2333 $12.0 $34.00 34.00 1,000.00 $3';
if(preg_match_all('/\$?\d+(?:\.\d+)?/ims',$text,$matches)){
trigger_error(var_dump($matches, true));
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER