Testing whether a String Contains Only Numeric Data - Node.js String

Node.js examples for String:String Value

Description

Testing whether a String Contains Only Numeric Data

Demo Code

function isNumeric(str) {
  var pattern = /^-?\d+(\.\d+)?$/;
  return pattern.test(str);
}

Related Tutorials