Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Single regex

by Anonymous Monk
on Jan 10, 2013 at 16:47 UTC ( #1012698=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Please tell me how to write a single regex which matches all the above conditions.

Replies are listed 'Best First'.
Re: Single regex
by choroba (Chancellor) on Jan 10, 2013 at 16:54 UTC
    You probably do not want to see
    m{^(?: ntv\.com/very-own/ | ntv\.com/business/ | ntv\.com\.wid-prl\.com/very-own/ | ltv\.com/very-own/ )$}x
    as the answers. Tell us more: What conditions should it not match? What are you trying to achieve?
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Single regex
by BrowserUk (Pope) on Jan 10, 2013 at 16:57 UTC

    print "$_: ", m[[nl]tv\.(?:com\.wid-prl\.)?com/(?:business|very-own)/] + ? 'matches' : 'nomatch' for qw[ ];; matches matches matches matches

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      good code, but I would add ^ and $
Re: Single regex
by clueless newbie (Chaplain) on Jan 10, 2013 at 18:03 UTC

    Using Regexp::Assemble

    use strict; use warnings; use Regexp::Assemble; my $re=Regexp::Assemble->new(); $re->add('ntv\.com/very-own/'); $re->add('ntv\.com/business/'); $re->add('ntv\'); $re->add('ltv\.com/very-own/'); print $re->re."\n";


Re: Single regex
by muba (Priest) on Jan 10, 2013 at 16:57 UTC
Re: Single regex
by 0day (Sexton) on Jan 10, 2013 at 17:01 UTC
Re: Single regex
by Anonymous Monk on Jan 11, 2013 at 02:37 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1012698]
Approved by muba
[Corion]: marto: Currently all well - work is even OK currently ;) I should start translating my WWW::Mechanize:: Chrome talk to English and recheck that my demos all work, but I have two weeks for that still :)
[Corion]: So, most things are looking good :-D
[Corion]: I should write some more code for my Jekyll clone, but I don't feel like it, so maybe I should just let that linger instead ;)
[karlgoethebier]: "...mein enemy..."
[marto]: it has finally stopped raining!
[Corion]: marto: Heh - we've got the rain here, now. But it's only intermittently, not permanent. But funny that you should complain about rain ;)
[Discipulus]: rain? i dont remember it..

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-07-26 10:50 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (390 votes). Check out past polls.