1

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

Himanshu Shekhar
  • 1,196
  • 1
  • 16
  • 35

5 Answers5

6

Try this it will help you

Less than 18 and greater than 99 is not allowed

^(1[89]|[2-9][0-9])$
anubhava
  • 761,203
  • 64
  • 569
  • 643
Shoaib Quraishi
  • 232
  • 2
  • 17
4

^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
AndrewR
  • 6,668
  • 1
  • 24
  • 38
1

Try this:-

^0?(1[89]|[2-9]\d)$

Demo: https://regex101.com/r/CrcbHN/1

Gurmanjot Singh
  • 10,224
  • 2
  • 19
  • 43
0

(01[89])|(0[2-9]\d)

  • (01[89]) matches 018 to 019
  • (0[2-9]\d) matches 020 to 099
voskhod
  • 194
  • 12
0

Try with below,

0([1][89]|[2-9][0-9])

DEMO

Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45