in reply to Re^2: Global regexp
in thread Global regexp

Which is to be expected, because my approach never matches anything in the "real body" of the regular expression. If you want different behaviour of the regex engine, you can only achieve that by making it match different things, which will result in the match variables containing different values. If you want to keep the behaviour of $`, $& and $', then you will need to fiddle with pos. You haven't stated why you don't want to do that.

Replies are listed 'Best First'.
Re^4: Global regexp
by Anonymous Monk on Jun 17, 2008 at 12:24 UTC
    I think dealing with pos will result in ugly code: maybe code with cycle over string length or time consuming code.
    So you mean perl regexps are always greedy: they match as much as possible and there's no way to configure them beside your approach with (?= ) ?

      Basically yes - Perl regular expressions will always match the leftmost longest match. Any other approaches will need other regular expression engines. If you're running Perl 5.10, you have the option of using different regular expression engine (see re::engine).

        Thanks for clear explanation of perl insides.