in reply to Re: Why isn't this regex greedy?
in thread Why isn't this regex greedy?

Aha!

I thought it must be something like that - the issue that I was uncertain about what was what the neg-lookahead was applied to. It would seem it applies to the .{1,5} rather than the 'foo'.

Slightly non-intuitive IMHO, but I've got it now...

Tom Melly, tom@tomandlu.co.uk

Replies are listed 'Best First'.
Re^3: Why isn't this regex greedy?
by demerphq (Chancellor) on Mar 17, 2006 at 10:44 UTC

    "Lookahead" implies "characters following", if it was "lookbehind" it would be "characters preceding". "negative lookahead" means that the following characters can not match. "Negative lookbehind" would mean that the preceding characters can not match.

    ---
    $world=~s/war/peace/g