[Neworleans-pm] need a little help with a RegEx

Alex Walker alex at houseofwalker.net
Tue Jan 31 06:40:09 PST 2006


Good morning all.

This should be easy, but somehow I'm missing something. I'm inserting tags in a set of HTML files based on a couple of criteria. What I want to do is find every instance of "<p class=imagecenter>" containing an image with a "usemap" tag and insert div tags around the paragraph. The HTML is a little ugly since it was generated by a WYSIWYG editor (sorry, it was like that when I got here), although the files are all relatively short I can assume that all paragraphs contain a closing "</p>". The easiest thing seemed to be to just slurp it and look for everything between a  "<p class=imagecenter>" and "</p>", but it's not working.

Here's the problem... everything works like a champ when there is a "usemap" tag, but on instances where that tag is not there, the script still seems to be picking up the initial "<p class" tag and then just never closing it. I've attached a sample HTML file and a trimmed down version of the script. You'll see that the first image works fine but the second (which should just be skipped) causes all kinds of problems. I'm sure there's just some dumb thing that I'm missing here, but I really can't see it. Any help would be much appreciated.

Thanks,
Alex



-------------- next part --------------
A non-text attachment was scrubbed...
Name: zz.htm
Type: application/octet-stream
Size: 3866 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/neworleans-pm/attachments/20060131/d525896b/zz.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapimages.pl
Type: application/octet-stream
Size: 612 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/neworleans-pm/attachments/20060131/d525896b/mapimages.obj


More information about the NewOrleans-pm mailing list