Ask Your Question
1

How can I design a regex pattern that only allows numbers between 1 and 100 and rejects any other input?

asked 2022-06-02 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-12-12 00:00:00 +0000

qstack gravatar image

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

Explanation: - ^ : Start of line - (?: ) : Non-capturing group - [1-9][0-9]? : Matches numbers 1-9, 10-99 - | : OR - 100 : Matches 100 - $ : End of line

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-06-02 11:00:00 +0000

Seen: 10 times

Last updated: Dec 12 '22