Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reg Ex - not allowing zero

Excuse my ignorance. My knowledge of regular expressions is extremely limited.

I have the following regular expression on a regular expression validator.

^(\d{1,3},?(\d{3},?){0,2}\d{3}|\d{1,3})$

It currently allows zero. I need to update it so that it does not allow a value of 0.

[Edit: Just to clarify, I would like it to exclude a value of zero rather than a singular "0" - thanks]

Any help would be greatly appreciated.

Thanks zaps

like image 514
Riain McAtamney Avatar asked Jan 19 '26 08:01

Riain McAtamney


1 Answers

You may be looking for something like this:

^[1-9]\d{0,2}(\d*|(,\d{3})*)$
like image 178
reinierpost Avatar answered Jan 20 '26 21:01

reinierpost