I'm creating a calendar where users can set events and time in single line, for example:
"6pm supper" - event with start time only
"8:00 - 16:00 work" - event with time period
Regex I'm currently using to get times:
[\d]{1,2}[.|:]?[\d]{0,2}[\s]?[am|pm|AM|PM]{0,2}
It works fine but I can't figure out how to filter out the unwanted occurrences of time if they happen, for example:
"6pm supper at '8pm' restaurant" In this example '8pm' is a restaurant name but it will be interpreted as event with time period while it's not. I suppose I have to write a regex that will only match time pattern in the beginning of line and the next pattern that follows after it without any words between but I have no success composing such a regex so far.
Any suggestions?