S
S
SHentai2018-05-06 11:50:36
Regular Expressions
SHentai, 2018-05-06 11:50:36

Regular expressions, how to check for a number from 1 to 12?

Hello.
there is this: /^[1-9]$/, but I need to check that there is only one digit and it is from 1 to 12. How can I do this?)
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nick Sdk, 2018-05-06
@SHentai

^([1-9]|1[0-2])$
https://regex101.com/r/r8FC3E/1

L
Lander, 2018-05-06
@usdglander

Monsieur, checking the range of a number through a regular expression is such an idea. Why not use if?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question