I am trying to find a solution to extract the time given in a dynamic string using regex object using JavaScript.
For example - Assume the string to be "Please provide access to the engineer: last name: XYZ first name: ABC date: 02nd November 2021 time window: 11:00AM - 07:00PM CET". I need to extract the time i.e 11:00AM - 07:00PM CET from this.
I tried using the regex expression for time -
/^(0?[1-9]|1[0-2]):([0-5]\d)\s?((?:A|P)\.?M\.?)$/i
and few more other expressions. However whenever I test the returned value is false.
What is the approach to solve this ?