Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression for minimum value 18 and maximum 99 with leading zero

Regular Expression for minimum value 18 and maximum 99 with leading zero. Means my number should be from 18 to 99. With one condition of leading zero i.e 18 == 018, 99 == 099

like image 835
Himanshu Shekhar Avatar asked Feb 19 '26 23:02

Himanshu Shekhar


2 Answers

Try this it will help you

Less than 18 and greater than 99 is not allowed

^(1[89]|[2-9][0-9])$
like image 109
Shoaib Quraishi Avatar answered Feb 21 '26 14:02

Shoaib Quraishi


^0?1[89]|0?[2-9][0-9]$

  • ^ - beginning of string
  • 0? - allow beginning 0
  • 1[89] - match first character 1 and second 8 or 9
  • | - or
  • 0? - allow beginning 0
  • [2-9] - match first character 2-9
  • [0-9] - match second character 0-9
  • $ - end of string
like image 41
AndrewR Avatar answered Feb 21 '26 13:02

AndrewR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!