var reg = /^\d+$/;
should do it. The original matches anything that consists of exactly one digit.
More Related Contents:
- Regex – To allow numeric, only characters R, N, X, B, @ [closed]
- Find particular string from URL in JavaScript
- Regex for Email Address along with name format [duplicate]
- JavaScript regex multiline text between two tags
- Case insensitive regex in JavaScript
- I want to remove double quotes from a String
- Match only unicode letters
- Matching exact string with JavaScript
- Finding Plus Sign in Regular Expression
- Combining regular expressions in Javascript
- How can I select an element by ID with jQuery using regex?
- Regex to Match Symbols: !$%^&*()_+|~-=`{}[]:”;’?,./
- Javascript regex returning true.. then false.. then true.. etc [duplicate]
- How can I replace newlines/line breaks with spaces in javascript?
- How do I split a string by whitespace and ignoring leading and trailing whitespace into an array of words using a regular expression?
- Remove specific HTML tag with its content from javascript string
- Can I use a regular expression in querySelectorAll?
- Regex remove repeated characters from a string by javascript
- Regex only capturing last instance of capture group in match
- Javascript RegExp for splitting text into sentences and keeping the delimiter
- Best way to parse HTML in Javascript
- Commenting Regular Expressions
- JavaScript Regex to match a URL in a field of text
- How can I use regex to get all the characters after a specific character, e.g. comma (“,”)
- Regex JavaScript image file extension [closed]
- Removing backslashes from strings in javascript
- Why this regex is not working for german words?
- I would like to mimick conditionals in javascript regex
- Get text between two rounded brackets
- Preg_match to regex equivalent expression to match any Unicode letters