Message: 3
Date: Tue, 16 May 2006 11:10:48 -0500
From: "Curtis Leach" <[EMAIL PROTECTED]>
Subject: RE: Need help with IMG tag containing unbalanced parentheses
To: [email protected]
Message-ID:
 <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

Nice example program below, but it does have a bug in it.  Here is the
fix.


    $str1 =~ s/<IMG[^>]*>/<IMG = IMAGE REMOVED>/gi;
-------------------------------
hehe. Curtis, you missed one issue, greedy v non-greedy. you want to stop 
at the first > one comes to. what if the input is something like:
-----example-----
<p>this is a picture of an elephant <img src="elephant.jpg" alt="an 
elephant" /></p>
<p>this is a picture of a monkey <img src="monkey.jpg" alt="a monkey" 
/></p>
<p>this is a picture of a spider <img src="spider.jpg" alt="a spider" 
/></p>
-----end example-----

so i would use 
    $str1 =~ s/<IMG[^>]*?>/<IMG = IMAGE REMOVED>/gi;

however last time i did something with html parsing i used HTML parser 
since i found it less of a headache.
so obviously i feel the previous suggestion to use it is the best answer 
so far. the other one i think was good was to ask for clarification of how 
much of the tag to remove. 

HTH
-Josh
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to