use strict; use warnings; use Regexp::Common qw /URI/; my $string = "xxx http://perlmonks.com yyy http://foo.mp3 zzz"; $_ = $string; my @urls = grep {/\.mp3$/} /($RE{URI}{HTTP})/g; local $" = "\n"; print "@urls\n"; OutPUT: http://foo.mp3