4

This expression is to check number > 1

^[1-9]+[0-9]*$

  • what is the expression to check if it's greater than a given value, say "99" ?
  • what about a value less than, 99?

Update:

I'm using ASP.NET validation control.

Thanks.

Narazana
  • 1,940
  • 15
  • 57
  • 88

2 Answers2

6

You say this is homework, so I'll give my answer for greater than 57 instead; you can take the idea and modify it.

/^([6-9][0-9]|5[89]|[1-9][0-9]{2,})$/

If you don't have the {a,} construct,

/^([6-9][0-9]|5[89]|[1-9][0-9][0-9]+)$/
Martin
  • 37,119
  • 15
  • 73
  • 82
Charles
  • 11,269
  • 13
  • 67
  • 105
1

I agree with @Rowlf comment! You should not need a regex for doing this (unless this is an interview question :) ) . Just use '>'.

Well, your given regex ^[1-9]+[0-9]*$ is matches >=1 not only >1

Gopi
  • 10,073
  • 4
  • 31
  • 45