http://www.perlmonks.org?node_id=1012845


in reply to match the urls

use 5.010; use strict; use warnings; my @urls = qw< 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-political-news/fgdfgd https://www.abc.com/ap/ap/top-news/ https://www.abc.com/ >; for (@urls) { m{ ^ https://www\.abc\.com/ # correct stem (?: .+? / ){3} # non-greedy string then slash x 3 .+ # at least one other character }x ? say("MATCH: $_") : say("NOT: $_") }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'