Friday, 23 August 2013

Regex to get currency and amount from string

Regex to get currency and amount from string

I have an Regex with me preg_match('/(?<=\$)\d+(\.\d+)?\b/', $str, $regs
which return me the amount in a currency, but what i am trying is to get
the symbol associated with the amount too.
1) E.g. the string is $300.00 asking price should return $300.00 but now
it returns 300
2) E.g. the string is EUR 300.00 should return EUR300.00 but now it
returns 300

Simply i want the currency with amount.
Thanks

No comments:

Post a Comment