List of utility methods to do Regex Number Validate
boolean | isNumeric(String str) is Numeric Matcher isNum = pattern.matcher(str); if (!isNum.matches()) { return false; return true; |
boolean | isNumeric(String text) Validation method for Number Format (decimal is excluded) if (isEmpty(text)) { return false; Pattern p = Pattern.compile("[0-9]*"); return p.matcher(text.trim()).matches(); |
boolean | isNumeric(String value) Indicates whether the given value is numeric. return NUMERIC_PATTERN.matcher(value).matches();
|
boolean | isNumericAndCanNull(String src) is Numeric And Can Null Pattern numericPattern = Pattern.compile("^[0-9]+$"); if ((src == null) || (src.equals(""))) return true; boolean return_value = false; if ((src != null) && (src.length() > 0)) { Matcher m = numericPattern.matcher(src); if (m.find()) return_value = true; ... |
boolean | isNumericAndCanNull(String src) is Numeric And Can Null Pattern numericPattern = Pattern.compile("^[0-9]+$"); if (src == null || src.equals("")) return true; boolean return_value = false; if (src != null && src.length() > 0) { Matcher m = numericPattern.matcher(src); if (m.find()) { return_value = true; ... |
boolean | isNumString(String txt) is Num String return isEqualsFormat("^\\d+(,\\d+)*$", txt); |
long | parseNumber(String in) parse Number in = in.trim(); in = in.replaceAll(",", "."); try { return Long.parseLong(in); } catch (NumberFormatException e) { final Matcher m = Pattern.compile("([\\d.,]+)\\s*(\\w)").matcher(in); m.find(); ... |
int | parseNumber(String input) parse Number int num; if (containsNumbers(input)) { input = stripNumber(input); num = Integer.parseInt(input); } else throw new NumberFormatException("Not a readable number \"" + input + "\""); return num; |
int | parseNumber(String input) parse Number int num; input = onlyNums.matcher(input).replaceAll(""); if (input.length() > 0) num = Integer.parseInt(input); else throw new NumberFormatException("Not a readable number \"" + input + "\""); return num; |
long | parseNumber(String s) parse Number if (!isInitialized) init(); s = s.toLowerCase(); try { return Long.parseLong(s); } catch (NumberFormatException e) { if (numberValues.containsKey(s)) { return numberValues.get(s); ... |