I’m trying to extract the time from the following strings using regex
Free concert at 8 pm over there
Free concert at 8pm over there
Free concert at 8:30 pm over there
Free concert at 8:30pm over there
Does anybody know how to do this using Regex in java?
I’ve tried the following (1[012]|[1-9]):[0-5]0-9?(?i)(am|pm) but I dont think it allows for words before or after.
Thanks!
Try this one:
(?i)at (.+?) overExample:
Output:
Another one (only time, without at / over or any other word):
But there you dont need
group(1)(you can takegroup(0)or simplygroup())!Example: