79085274

Date: 2024-10-14 08:16:39
Score: 0.5
Natty:
Report link

I would recommend the following regex ("-?\d+(\.\d+)?") to match all positive and negative numbers that can be either int/long/double/float...whatever.

private Pattern pattern = Pattern.compile("-?\\d+(\\.\\d+)?");

public boolean isNumeric(String strNum) {
    if (strNum == null) {
        return false; 
    }
    return pattern.matcher(strNum).matches();
}
Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Thend