Skip to content

Instantly share code, notes, and snippets.

@sleepless-se
Created May 11, 2019 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sleepless-se/492abc6e4d87b64c453ea75f7ec3a363 to your computer and use it in GitHub Desktop.
Save sleepless-se/492abc6e4d87b64c453ea75f7ec3a363 to your computer and use it in GitHub Desktop.
This method get price from text.
package regex.com;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Regex {
public static String toPrice(String text) {
text = text.replace(",","");
Pattern p = Pattern.compile("[\\d.]+\\d");
Matcher m = p.matcher(text);
String price = "";
while (m.find()) {
return m.group();
}
return "not found price";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment