in reply to Re: Weird Regexes Stuff
in thread Weird Regexes Stuff

The updated solution still has a problem, IMO, with that pesky  \W anchoring the start of the match. Is the following really what you intend?

>perl -wMstrict -le "my $input = '12:00am, 5:00pm,8:30AM'; while ($input =~ m/\W([1-9]|[01][0-2]|2[0-3]):[0-5][0-9][ap]m/gsi) { print qq{This is a valid time!\t$&}; } " This is a valid time! 5:00pm This is a valid time! ,8:30AM