What is the meaning of /i
at the tail of this regex?
var time = /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/i;
What is the meaning of /i
at the tail of this regex?
var time = /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/i;
/i
stands for ignore case in the given string. Usually referred to as case-insensitive as pointed out in the comment.
It's, like Sachin Shanbhag already answered the 'ignore case' modifier. So /[a-z]/i
is equal to /[a-zA-Z]/
. Check this link for other modifiers.
© 2022 - 2024 — McMap. All rights reserved.
[a|p]
matchesa
,|
orp
(yes, the|
as well!). Inside a character set, the pipe has no special meaning. So you'll probably want to do:[ap]m
which matchesam
orpm
. – Hypnos([1-9]|1[0-9])
will only match'1'
,'2'
,'3'
, ... ,'19'
. Is that correct? – Hypnosdigits-digits
i.exxxx-xx
i.e n digits n then-
and then one or two digits, my regex will look like this?/^\d+-\d{1,2}$/
or something else? – Tonguing