Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex match numerical range

I am trying to write a simple regex to match a percentage value range 1%-100%

Is there a better way to write this?

^([1-9]|[1-9][0-9]|100)%$
like image 740
Gabe Avatar asked Feb 24 '26 13:02

Gabe


1 Answers

You can make it a bit shorter:

^([1-9][0-9]?|100)%$
like image 120
SLaks Avatar answered Feb 27 '26 03:02

SLaks