从字符串中匹配出金额
//匹配字符串中的金额
String str = "例如这是200.34元";
Pattern pattern = Pattern.compile("[+-]?\\d+(?:\\.\\d{0,2})?");
Matcher matcher = pattern.matcher(str);
if (matcher.find()) {
String money = matcher.group();
}
从字符串中匹配出金额
//匹配字符串中的金额
String str = "例如这是200.34元";
Pattern pattern = Pattern.compile("[+-]?\\d+(?:\\.\\d{0,2})?");
Matcher matcher = pattern.matcher(str);
if (matcher.find()) {
String money = matcher.group();
}