I have a String that contains formatted currency values, such as 45,890.00several values separated by commas, like 45,890.00,12,345.00,23,765.34,56,908.50..
I want to extract and process all currency values, but could not find the correct regular expression for this. This is what I tried
public static void main(String[] args) {
String currencyValues = "45,890.00,12,345.00,23,765.34,56,908.50";
String regEx = "\\.[0-9]{2}[,]";
String[] results = currencyValues.split(regEx);
for(String res : results) {
System.out.println(res);
}
}
The result of this:
45,890
12,345
23,765
56,908.50
Can someone please help me with this?
source
share