0

Hi People I am very new at Regex. I found out that 0-99 has expression "(?:\b|-)([1-9]{1,2}[0]?|99)\b" and 100-200 has "[1-2]\d\d".

I wanted to find out how it would be to write a range 9990001 - 9999991.

Any answer which makes it work would be gladly appreciated. Thanks

2 Answers2

2

You can use

999[0-9]{2}([0-8][0-9]|91|90)

999 litteral

[0-9]{2} 2 numbers

([0-8][0-9]|90|91) 0 to 8 with any number or 91 or 90

Test it yourself

p.s. I agree with @ikleschenkov That you should just use an if stament with that range when possible. Regex is not the best (and not even fastest) tool for this kind of problem.

online Thomas
  • 8,864
  • 6
  • 44
  • 85
0

You have 3 options with 0X (X more than 0) , 1-8X and 9X (X up to 1):

999[0-9][0-9][0][1-9]|999[0-9][0-9][1-8][0-9]|999[0-9][0-9][9][0-1]
Ori Marko
  • 56,308
  • 23
  • 131
  • 233