lundi 2 mars 2015

Filter out the price or cost in the Java

I have got ((?:[0-9]{1,3}[\.,]?)*[\.,]?[0-9]+) to filter out the prices in a string on java so I put them like this:



public static final String new_price = "((?:[0-9]{1,3}[\\.,]?)*[\\.,]?[0-9]+)";

final Pattern p = Pattern.compile(new_price, 0);
final Matcher m = p.matcher(label);
if (m.matches()) {
Log.d(TAG, "found! good start");
if (m.groupCount() == 1) {
Log.d(TAG, "start match price" + " : " + m.group(0));
}
if (m.groupCount() == 2) {
Log.d(TAG, "start match price" + " : " + m.group(1));
}
}


I got the sample working on http://www.regexr.com/ but it never found the matches on the run time. Any idea??


Aucun commentaire:

Enregistrer un commentaire