Skip to content

Commit

Permalink
Use better amount format pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
imDaniX committed Sep 12, 2023
1 parent 87a75c4 commit 27e2b5e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static com.earth2me.essentials.I18n.tl;

public class Commandpay extends EssentialsLoopCommand {
private static final Pattern NUMBER_FORMAT = Pattern.compile("([0-9][0-9_'`,]*(?:\\.[0-9]+)?|\\.[0-9]+)([kmbt])?");
private static final Pattern AMOUNT_FORMAT = Pattern.compile("((?:[0-9][_'`,]?)+(?:\\.[0-9]+)?|\\.[0-9]+)([kmbt])?");
private static final Pattern SANITIZE = Pattern.compile("[^0-9.]");

private static final BigDecimal THOUSAND = new BigDecimal(1000);
Expand All @@ -43,7 +43,7 @@ public void run(final Server server, final User user, final String commandLabel,
throw new Exception(tl("payMustBePositive"));
}

final Matcher formatMatcher = NUMBER_FORMAT.matcher(amountStr);
final Matcher formatMatcher = AMOUNT_FORMAT.matcher(amountStr);
if (!formatMatcher.matches()) {
throw new Exception(tl("numberRequired"));
}
Expand Down

0 comments on commit 27e2b5e

Please sign in to comment.