I'm attempting to match a timecode in the format of "0000" to "2459". How can I match numbers in a specific range, so that I could specifically match all numbers between 0 and 24 and all numbers between 0 and 59, and nothing greater or lesser?
I know how to match each individual digit, but that won't do what I want because for example
/[0-2][0-4]/
would capture numbers 0-4, 10 - 14, and 20-24, missing those in between. So I want to capture all inclusive for multiple digits.
The following should do the trick:
/(?:[01][0-9]|2[0-4])[0-5][0-9]/
Explanation:
?:
makes the parentheses non-capturing.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