#!/usr/bin/perl use strict; use warnings; my @array = ('https://www.abc.com/ap/ap/top-news/76/nTk3M/','https://www.abc.com/videos/news/eye-catching/vmxJr','https://www.abc.com/ap/top/45/state-politic al-news/fgdfgd', 'https://www.abc.com/ap/ap/top-news/', 'https://www.abc.com/'); my @b = grep {$_ =~ /\w+\:\/\/\w+\.\w+\.\w+\/(\w+\-?\w+?\/){3,}./ } @array; print "@b";