Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How do I write a regex for 'does not contain' a string.

by fruiture (Curate)
on Aug 09, 2002 at 14:25 UTC ( [id://188916] : note . print w/replies, xml ) Need Help??


in reply to How do I write a regex for 'does not contain' a string.

Well, I'd suggest you do not want to do what your question's title asks for (and what Abigail has already told you). You already can see it in your first attempts on solving your problem: you won't match img elements that have an attribute different from src in the beginning. You will miss elements, that have 'display:block' in their title-attribute. You will somehow produce duble style-attributes inmany cases...

The solution is to use HTML::Parser or HTML::Tokeparser to fastly run through the text and extract img elements and explicitly check the style attribute for the display-property and add it if not present. That may be a bit slower in the end, but it will get all cases and produce good results.

--
http://fruiture.de
  • Comment on Re: How do I write a regex for 'does not contain' a string.