hi,
i wanted to code a function for time validation using regular expressions, but i could not 🙁
e.g. : "14:12" >> validated (24 Hour format)
can anyone help me or send a piece of code for that ???
regards..
Originally posted by HardNDark hi, i wanted to code a function for time validation using regular expressions, but i could not 🙁 e.g. : "14:12" >> validated (24 Hour format) can anyone help me or send a piece of code for that ??? regards..
N
Why use regular expressions? Just split it into two pieces - the bit before the ":" and the bit after. Then make sure that the first bit is between 00 and 23 inclusive, and the second bit is between 00 and 59 inclusive.
Originally posted by Weedpacket Why use regular expressions?
i am not sure but i think regular expressions will work faster?
is it right??
Not necessarily. If you like you can use a regexp to ensure that what you've got is a pair of digits then a colon then a pair of digits, and at the same time capture those two pairs; that's reasonable.
But for checking that those pairs of digits are in the right range regular expressions are the wrong thing to use - not when you can just use "<=" and ">=" instead.