c# - RegularExpressionValidator returns false for valid input -
i trying validate time zone offset has format of optional minus sign, followed 2 digits, followed colon followed 2 more digits; -05:00 or 04:30. used \b[-]?\d{2}:\d{2}\b validation expression, tested on online re testing sites , "successful match" validator keeps returning falase. can't see doing wrong. enter -05:00 or -13:99 , both return false. tried escape colon same thing.
drop word boundaries you'll matches.
-?\d{2}:\d{2}
if want first occurrence make this:
-?\d{2}:\d{2}$
if want match valid times use one:
-?([0-2][0-3]|[0-1][0-9]):([0-5][0-9])
the above 1 matches hour in range of 0-23:0-59 btw.
Comments
Post a Comment