-2

How to write a regular expression that will pass a numbers from 60 to 99?

Greg
  • 481
  • 1
  • 5
  • 21
Oleg Gordiichuk
  • 15,240
  • 7
  • 60
  • 100

5 Answers5

7

Fairly straightforward:

/^[6-9][0-9]$/

But why are you using regex for this?

Amber
  • 507,862
  • 82
  • 626
  • 550
3

Regular expressions is a poor tool for such task. You should really drop to a numerical comparison.

But since you ask, here's how:

/^[6-9][0-9]$/

Related questions:

Community
  • 1
  • 1
aioobe
  • 413,195
  • 112
  • 811
  • 826
3

I would probably do it by checking via ($n >= 60 && $n <= 99), but a possible regex is:

/^[6-9][0-9]$/
Carsten
  • 17,991
  • 4
  • 48
  • 53
2

[6-9][0-9]

shift66
  • 11,760
  • 13
  • 50
  • 83
1

could also use an if case:

if($value >= 60 && $value <= 99) { // do stuff}
René Höhle
  • 26,716
  • 22
  • 73
  • 82
Nicholas
  • 5,430
  • 3
  • 21
  • 21