-1

I have to say I'm not very experienced in Reg. Expressions

Regex:

 ^[1-9]?[0-9]{1}$|^100$

I would like to test a number between 1 and 100, excluding 0

Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115
Yulimar
  • 83
  • 1
  • 9
  • 1
    [Regex number between 1 and 100](http://stackoverflow.com/a/13473595/3110638) – Jonny 5 Mar 14 '14 at 09:54
  • possible duplicate of [Reference - What does this regex mean?](http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – John Dvorak Aug 15 '14 at 04:33

3 Answers3

3
^[1-9][0-9]?$|^100$

this is starting at a digit between 1 and 9

and ending at an optional 0 to 9 \

demo here

aelor
  • 10,892
  • 3
  • 32
  • 48
1

Try this regex:

^(?:[1-9]\d?|100)$

Description

Regular expression visualization

Demo

http://regex101.com/r/pU5cM6

Stephan
  • 41,764
  • 65
  • 238
  • 329
0

Following regex will match numbers>=1 and numbers<=100

^([1-9][0-9]?|100)$
captainsac
  • 2,484
  • 3
  • 27
  • 48