To format properly data from third party service, I was wondering if this regex is concise enough:
(([\d,.]+))(1?\sR\$)
to change this:
from 200 R$ to 400 R$ (32 products)
into this:
from R$ 200 to R$ 400 (32 products)
to format this output, I am using Preg to replace the text with $3 $1 , as seen in http://www.regextester.com/
is this good enough or the regex is not adequate?
Regex:
(\d+[.,]?\d*)(\s*)(R\$)Replacement:
$3$2$1Test input:
Test output:
If you want to parse also decimal numbers with no leading zero, such as
.200, then use regex