You're not required to solve every problem with a regexp. Sometimes another
tool is more suitable.

Depending on the size of your data and the number of matches, Aho-Corasick
<http://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_string_matching_algorithm>
can be what you're looking for. There's a Perl implementation on CPAN.


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 ?
>
>
>
> Yossi
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Perl mailing list
> [email protected]
> http://mail.perl.org.il/mailman/listinfo/perl
>
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl

Reply via email to