Farhad-Taran
Farhad-Taran

Reputation: 6512

JavaScript compatible regexp to disallow a zero or any chars?

I need a regex to disallow:

 0
 0123
 abcd-)(^&%$!"!"£ etc`

to allow:

1234567890

I have the following so far but it fails

/^[1-9]|[1-9]\d+$/

Upvotes: 1

Views: 80

Answers (1)

jcubic
jcubic

Reputation: 66498

Try this regular expression

/^[1-9][0-9]*$/

Upvotes: 4

Related Questions