in reply to Re: Why doesn't non-greediness work?
in thread Why doesn't non-greediness work?

actually perl is smart enough to avoid that.. in fact you can do something as disturbing as

$body =~ s;<img(.+?)="Wink">;\;;g;

which is why they say only perl can parse perl.

Replies are listed 'Best First'.
Re: Re: Re: Why doesn't non-greediness work?
by wolfger (Deacon) on May 13, 2003 at 15:13 UTC
    Yes, but notice that you escaped one of those semicolons... In the original, the semicolon that was part of the smiley was not escaped.

    The one serious conviction that a man should have is that nothing is to be taken too seriously. -- Nicholas Butler
      Please familiarize yourself with the quoting rules in Perl. All of the following work as well:
      $body =~ ss<img(.+?)="Wink">s;)sg; $body =~ s$<img(.+?)="Wink">$;)$g; $body =~ s,<img(.+?)="Wink">,;),g; $body =~ s[<img(.+?)="Wink">]\;)\g; $body =~ s}<img(.+?)="Wink">}{;)}g; $body =~ s&<img(.+?)="Wink">&;)&g; # .. ad nauseam

      Makeshifts last the longest.