On Thu, Aug 28, 2014 at 9:28 AM, Yossi Itzkovich <
[email protected]> wrote:

>  Hi,
>
>
>
> Sometime I want to find a line that contains 2+ patterns components, but I
> don’t mind the order of the components in the line.
>
> The naïve approach is to do one of the following code options
>
> 1.       /a.+?b/ or /b.+?a/
>
> 2.       /(?:a.+?b)|(?:b.+?a)/    (this one probably is more efficient)
>
>
>
> But I don’t feel comfortable with any of the above  (and when there are
> more than 2 components it gets worse).
>
>
>
> Is there a better way of doing it ?
>
>
>
>
>
if (/a/  and /b/) {
}

and if you have more regexs all of them in @regexes   then

my @regexes = (qr/a/, qr/b/, qr/c/);

use List::MoreUtils qw(all);
if (all { /$_/ } @regexes) {
}


Gabor
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl

Reply via email to