4

I need a regular expression to find a number in the range [40010-40100]. I tried with this 40[0-1][0-9][0-9] but it doesn't work. Could someone help me?

skink
  • 5,133
  • 6
  • 37
  • 58
Katie
  • 609
  • 1
  • 6
  • 17
  • 9
    This is not a good use of regular expressions. What scripting language are you using? – Jason McCreary May 16 '11 at 14:05
  • possible duplicate of [Regular Expression: Numeric range](http://stackoverflow.com/questions/1377926/regular-expression-numeric-range) – Marijn Jun 14 '12 at 08:37

4 Answers4

5

This should do : (40100|400[1-9][0-9])

krookedking
  • 2,203
  • 20
  • 21
2

Here you go...

40(0([1-9][0-9])|100)

CrayonViolent
  • 32,111
  • 5
  • 56
  • 79
1

Try the following

40((0[1-9][0-9])|(100))

Although this is not a great task for a regular expression. It would be much easier to simply do a range comparison on the number

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
1

/400[1-9][0-9]|40100/

Why oh why can't I just post the answer without an "Oops!"?

e.dan
  • 7,275
  • 1
  • 26
  • 29