Created
May 11, 2019 06:01
-
-
Save sleepless-se/492abc6e4d87b64c453ea75f7ec3a363 to your computer and use it in GitHub Desktop.
This method get price from text.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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