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,038
  • 1
  • 16
  • 32

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
  • 713,503
  • 59
  • 514
  • 593
Shoaib Quraishi
  • 202
  • 2
  • 16
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,510
  • 1
  • 21
  • 38
1

Try this:-

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

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

Gurmanjot Singh
  • 9,774
  • 2
  • 19
  • 39
0

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

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

Try with below,

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

DEMO

Abhishek Gurjar
  • 7,330
  • 10
  • 37
  • 44