Skip to content

Commit

Permalink
fixed #2576 numeric comparaison support negative.
Browse files Browse the repository at this point in the history
  • Loading branch information
vertigo17 committed Feb 7, 2025
1 parent 0065943 commit ad7d804
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/src/main/java/org/cerberus/core/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,19 @@ public static boolean isBoolean(String str) {
}

/**
* This method just reformat a string in order to increase the change it can
* This method just reformat a string in order to increase the chance it can
* get converted to float. For ex, it replace , with .
*/
public static String prepareToNumeric(String str) {
String result = str.replaceAll("[^0-9.,]", "");
String result = str.replaceAll("[^0-9.,-]", "");
if (result.contains(",")) {
result = result.replace(",", ".");
}
if (result.startsWith("-")) {
result = "-" + result.replace("-", "");
} else {
result = result.replace("-", "");
}
int i = 0;
while (nbChars(result, ".") > 1 && i++ < 100) {
result = result.replaceFirst("\\.", "");
Expand Down

0 comments on commit ad7d804

Please sign in to comment.