You can use regex to analyze your result in a web service. You must filter out all characters except numbers, periods, and spaces. Here is the regex for this:
String regexp = "[^0-9\\.,\\s]*";
The first group of the result of the match is the currency symbol (or name, for example, EUR).
Here is my example:
public void test() throws Exception { String text = "2.02 $"; String regexp = "[^0-9\\.,\\s]*"; Pattern p = Pattern.compile(regexp); Matcher m = p.matcher(text); while (m.find()) { for (int i = 0; i < m.groupCount() + 1; i++) LOG.info(m.group(i)); } }
ben_muc
source share