Regex to allow a user to type in a time - C#

Viewed 229

Lots of other questions give answers for regex expressions which only allow fully completed times like this: ^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$

But this is no use in a Textbox.TextChanged event because while typing 15:45 the textbox will contain 15: which doesn't match the expression above.

Is there an easy way to allow a partial match of a Regex expression to ensure a half typed time still passes or would I have to break the expression down into its parts all separated out by ors, like this?

1 Answers
Related