in reply to Re: Looking for N/A twice
in thread Looking for N/A twice

You can use a single regex regardless of order if you use look-ahead assertions.

$ perl -le ' > $_ = "gjhgjhgjg sata kjhkhkjhkjhkj N/A khkjhkhkhkj N/A"; > print q{ok} if m{(?ix) (?=.*\bn/a\b.+\bn/a\b) (?=.*\bsata\b)};' ok $

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^3: Looking for N/A twice
by polettix (Vicar) on Oct 22, 2007 at 06:58 UTC
    This struck me like a thunder:
    m{(?ix) (?=.*\bn/a\b.+\bn/a\b) (?=.*\bsata\b)}
    I thought that the span of application of (?ix) was the stuff inside the two parentheses (just like a contracted form of (?ix:)), but your regex clearly contradicts this. So I turned to the manpage and... it's there, nicely documented! I love this language.

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Io ho capito... ma tu che hai detto?