UNPKG

sectom

Version:

Sectom is a useful npm package that has multiple easy to use functions.

19 lines (16 loc) 438 B
/** * Removes all non numerical characters from a string * @example * onlyNumericalString('123abc') //123 * * @param {string} input * @returns */ function onlyNumericalString(input) { if (typeof input !== "string") throw new TypeError("the input must be a string!"); let myString = input; myString = myString.replace(/\D/g, ""); return myString; } exports.onlyNumericalString = onlyNumericalString;