if you want only integers, use:
/^-?\d+$/.test(v)
— EXPLANATION
^ – start of the string
-? – minus in the start, ?
means can be but not necessary
\d – any number (including zero)
+ – the last expression (=any number) can repeat more then once
$ – end of the string
More Related Contents:
- consider a string which has question marks, numbers , letters [closed]
- Regex for password must contain at least eight characters, at least one number and both lower and uppercase letters and special characters
- Escape string for use in Javascript regex [duplicate]
- What is a good regular expression to match a URL? [duplicate]
- How do I split a string with multiple separators in JavaScript?
- Restricting Character length in Regular expression
- Javascript date regex DD/MM/YYYY
- How can I strip all punctuation from a string in JavaScript using regex?
- Javascript regex hangs (using v8)
- Use dynamic (variable) string as regex pattern in JavaScript
- How to make Regular expression into non-greedy?
- How to replace captured groups only?
- Remove insignificant trailing zeros from a number?
- Unroll Loop, when to use
- Why does a simple .*? non-greedy regex greedily include additional characters before a match?
- JavaScript regex: Positive lookbehind alternative (for Safari and other browsers that do not support lookbehinds)
- Regex negative lookbehind not valid in JavaScript [duplicate]
- Regular Expression to reformat a US phone number in Javascript
- Validate phone number using javascript
- Javascript split string on space or on quotes to array
- Regex to remove spaces between ‘[‘ and ‘]’
- regex to get the number from the end of a string
- Converting Date and Time To Unix Timestamp
- JavaScript – string regex backreferences
- Regular Expression for accurate word-count using JavaScript
- JavaScript replace \n with [duplicate]
- What does the forward slash mean within a JavaScript regular expression?
- Extract keyword from Google search in Javascript
- Regex matching emoticons
- Regex: only alphanumeric but not if this is pure numeric