Help with regular expression for hours

Hello, I need some assistance, I have the following Entity in my bot


What I need it’s help with this, I want to capture time in a 12 hour format but I don’t want to restrict user input, so they can enter data as shown (i.e. 1:23 pm without a zero before 1)

Hi Saul,

Try this string “(((0?[1-9])|(1[0-2])):([0-5])([0-9])\s(a|p)m)”. I believe it fits all your requirements.

If you need to make modifications or when working with regex in future, a regex builder such as RegExr could be helpful.

2 Likes