in reply to Re^2: regex, use of lookaround for whole word filtering
in thread regex, use of lookaround for whole word filtering

You could probably make the first regex use a non-greedy .*

Wouldn't help.

>perl -E"$_='nor neither nor'; say !/neither.*nor/ && /nor/ ?1:0" 0 >perl -E"$_='nor neither nor'; say !/neither.*?nor/ && /nor/ ?1:0" 0

Non-greediness is very fragile and frequently misused.

Replies are listed 'Best First'.
Re^4: regex, use of lookaround for whole word filtering
by choroba (Cardinal) on Aug 11, 2010 at 10:36 UTC
    Two regexes with capturing in the first one, then:
    $test = "a nor b neither"; say $test =~ /(.*?nor)/i && $1 !~ /neither/i ? 1 : 0;