in reply to Strange regexp behavior

regular expressions are greedy. type
perldoc perlre /greed<enter>

perl -MLWP::Simple -e'getprint "http://parseerror.com/p"' |less

Replies are listed 'Best First'.
Re: Re: Strange regexp behavior
by aersoy (Scribe) on Mar 26, 2002 at 22:15 UTC

    Yes, but this regexp is not bitten by that. It would be, if the author had used (").*\1 instead. If you write s/"[^"]+"/--/g then:

    "word1" "word2"
    "word1" "word2
    "word1 "word2"

    will become

    -- --
    -- "word2
    --word2"

    --
    Alper Ersoy