Q: Extract time range Need some help with regex for extracting time from the following string:

3:00 am - 4:00 pm Transform data blah blah blah 

or 

3:00 am Transform data blah blah blah

Following regex works for the first format but it does not work for the second format: /\d{1,2}:\d\d\s([AaPp][Mm])?\s?-?\s\d{1,2}:\d\d\s([AaPp][Mm])/g

A: The modifier g allows finding all occurrences. Thus you can simplify your expression. Also the modifier i allows case insensitive matching. 
/\d{1,2}:\d{2}\s(am|pm)/gi

This is how to use :
var str = '3:00 am - 4:00 pm Transform data blah blah blah', 
times = str.match(/\d{1,2}:\d{2}\s(am|pm)/gi);
console.log(times);

times will be an array that contains the matches. 
