In java class I need regular expression for amount validation with the following conditions:
I write the following regular expression but it always return false
for both valid and invalid inputs.
Here's example:
private static final String PRICE_PATTERN = "((/d{1,4})(((//.)(/d{0,2})){0,1}))";
public PriceCheck() {
pattern = Pattern.compile(PRICE_PATTERN);
}
public boolean validate(final String username) {
matcher = pattern.matcher(username);
return matcher.matches(); // always return false;
}
请改用以下表达式:
private static final String PRICE_PATTERN = "((\\d{1,4})(((\\.)(\\d{0,2})){0,1}))";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.