Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

match the urls

by Anonymous Monk
on Jan 11, 2013 at 09:21 UTC ( #1012836=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Please help in writing the regex. match the url below
and not match
There should be some value after three "/"'s after the domain name and should match

Replies are listed 'Best First'.
Re: match the urls
by tobyink (Abbot) on Jan 11, 2013 at 09:38 UTC
    use 5.010; use strict; use warnings; my @urls = qw< >; 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'
Re: match the urls
by Anonymous Monk on Jan 11, 2013 at 09:25 UTC
Re: match the urls
by sen (Hermit) on Jan 11, 2013 at 14:35 UTC
    #!/usr/bin/perl use strict; use warnings; my @array = ('','https://w',' +p/45/state-politic al-news/fgdfgd', '', 'https://www.a'); my @b = grep {$_ =~ /\w+\:\/\/\w+\.\w+\.\w+\/(\w+\-?\w+?\/){3,}./ } @a +rray; print "@b";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1012836]
Approved by davido
[marioroy]: The MCE::Hobo::Pool module will come later.
[Corion]: marioroy: Oh, that's always cool, having API-compatible modules. This makes testing and comparing things much easier
[marioroy]: IPC in MCE::Shared can handle 400k (sends) per second. That's seems a lot for being a pure-Perl module. After making the release, will come back and post a solution for a node by a fellow wanting faster logging.
[Corion]: While working on WWW::Mechanize:: Chrome, I had the suspicion that AnyEvent was doing something wrong, but I was able to swap it out for Mojolicious and the error persisted.
[Corion]: Of course, the error was in my own code ;)
[marioroy]: Corion, start and start_child in MCE::Hobo::Manager return a MCE::Hobo object, whereas P::FM returns the PID. I can have it return the PID though. I tried Hobo::Manager with several P::FM modules, just changed P::FM to MCE::Hobo::Manager and it works.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-05-26 08:36 GMT
Find Nodes?
    Voting Booth?