To match only numbers except 0 using regex in JavaScript, you can use a negative lookahead to exclude the digit 0 from the match:
28 chars2 linesThis regular expression matches any string that starts with a non-zero digit and is followed by zero or more digits.
Here's an example of using the regex to test if a string is a non-zero number:
199 chars8 linesIn the example above, isNonZeroNumber is true because str is a non-zero number. isNonZeroNumber2 is false because str2 is the digit 0 which is excluded by the regex.
gistlibby LogSnag