-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
  • 26,578
  • 11
  • 57
  • 101
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
  • 9,803
  • 2
  • 27
  • 43
1

Try this regex:

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

Description

Regular expression visualization

Demo

http://regex101.com/r/pU5cM6

Stephan
  • 37,597
  • 55
  • 216
  • 310
0

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

^([1-9][0-9]?|100)$
captainsac
  • 2,384
  • 2
  • 23
  • 47