How to use 'regex numbers only' in JavaScript

Every line of 'regex numbers only' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
61function getRegex (isDecimal: boolean): RegExp {
62 return new RegExp(
63 isDecimal
64 ? `^(0|[1-9]\\d*)(\\${KEYS.DECIMAL}\\d*)?$`
65 : '^(0|[1-9]\\d*)$'
66 );
67}

Related snippets