Skip to content

Commit

Permalink
fix(SNSUNI-92): fix containsNonDigitChars() method, added exclusions …
Browse files Browse the repository at this point in the history
…for "-" and "e" to prevent false-positive condition for very low or very large numbers ie "1.0E-9"
  • Loading branch information
pjazdzyk committed Feb 26, 2024
1 parent 7a3a319 commit 08127eb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ private ParsingHelpers() {
}

/**
* Checks if the given input string contains any non-digit characters.
* Checks if the given input string contains any non-digit characters. Letter "e" and "-"
* are not counted as they may be part of very large or very small numbers ie: 1E-13.
*
* @param inputString The string to check
* @return True if the string contains any non-digit characters, false otherwise
*/
public static boolean containsNonDigitChars(String inputString) {
for (char nextChar : inputString.toCharArray()) {
String preparedString = inputString.toLowerCase()
.replace("-", "")
.replace("e", "");
for (char nextChar : preparedString.toCharArray()) {
if (Character.isAlphabetic(nextChar)) {
return true;
}
Expand Down

0 comments on commit 08127eb

Please sign in to comment.