regexstring

Regex number between 1 and 100


I would like to test a number between 1 and 100

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

Solution

  • Try:

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

    Working fiddle

    EDIT: IF you want to match 00001, 00000099 try

    ^0*(?:[1-9][0-9]?|100)$
    

    FIDDLE