How to check a string for validity using regular expressions?

Trying to do validation of strings using regular expressions.
Examples found on the Internet based on match() or test()
But this alone is not enough - if you just do str.match(/[0-9]/) the result is non-empty if str has at least one number. In this example, it is necessary that all characters in str have been numbers

In General I have yet to do so:
var str = '123';
var strIsValid = !!str.match(/[0-9]/) && str.match(/[0-9]/).input === str;

Tell me all so in the example or as something else to do?
June 8th 19 at 16:47
2 answers
June 8th 19 at 16:49
June 8th 19 at 16:51
or option for numbers not to exceed 9007199254740991
parseInt(str, 10).toString() === str
parseInt("NaN", 10).toString() === "NaN" // true

but the characters in the string is clearly not numeric - Willie.Berge commented on June 8th 19 at 16:54
Well , then for numbers less than 4294967197
(str >>> 0).toString() === str
by the way the version is also minus missed. - Marty93 commented on June 8th 19 at 16:57
but all this has nothing to do with the regexps

("01" >>> 0).toString() === "01" // false
Again - Willie.Berge commented on June 8th 19 at 17:00

Find more questions by tags Regular expressionsJavaScript