IraTarball has asked for the wisdom of the Perl Monks concerning the following question:
I was able to come up with something but it raised a question. Can you write a regex that matches all strings not containing the substring string 'foo'?
Here are my particular details...
this works, but it seems that I should be able to do this in a single s/// instead 2 matches and a swap. Thanks for taking the time to look at my post. I did a search for docs before posting but I could certainly have missed something. Pointers to pertinent nodes are appreciated.#!/usr/bin/perl while(<DATA>) { if(m/<img\s+src="\/images\/blank.gif"/ && !m/display:block/) { print; s|(<img\s+src="/images/blank.gif".*?)>|$1 style="display:block +">|; print; } } __DATA__ <img src="/images/blank.gif" border="0"> <img src="/images/blank.gif" border="0" style="display:block" > <img src="/images/blank.gif" border="0">
Ira,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I write a regex for 'does not contain' a string.
by Abigail-II (Bishop) on Aug 09, 2002 at 13:58 UTC | |
by IraTarball (Monk) on Aug 09, 2002 at 17:03 UTC | |
|
Re: How do I write a regex for 'does not contain' a string.
by arturo (Vicar) on Aug 09, 2002 at 15:14 UTC | |
by IraTarball (Monk) on Aug 09, 2002 at 16:59 UTC | |
|
Re: How do I write a regex for 'does not contain' a string.
by fruiture (Curate) on Aug 09, 2002 at 14:25 UTC |