I searched a lot and can't find the solution for this RegExp (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
Example: Regex Number Range 1-20 Range 1-20 has both single digit numbers (1-9) and two digit numbers (10-20). For double digit numbers we have to split the group in two 10-19 (or in regex: "1[0-9]") and 20. Then we can join all these with an alternation operator to get "([1-9]|1[0-9]|20)".
Python Regex – Get List of all Numbers from String. To get the list of all numbers in a String, use the regular expression '[0-9]+' with re. findall() method. [0-9] represents a regular expression to match a single digit in the string.
The Match-zero-or-more Operator ( * ) This operator repeats the smallest possible preceding regular expression as many times as necessary (including zero) to match the pattern. `*' represents this operator. For example, `o*' matches any string made up of zero or more `o' s.
To check for all numbers in a field To get a string contains only numbers (0-9) we use a regular expression (/^[0-9]+$/) which allows only numbers. Next, the match() method of the string object is used to match the said regular expression against the input value.
Try:
^[1-9][0-9]?$|^100$
Working fiddle
EDIT: IF you want to match 00001, 00000099 try
^0*(?:[1-9][0-9]?|100)$
FIDDLE
For integers from 1 to 100 with no preceding 0 try:
^[1-9]$|^[1-9][0-9]$|^(100)$
For integers from 0 to 100 with no preceding 0 try:
^[0-9]$|^[1-9][0-9]$|^(100)$
Regards
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With