in reply to Re: Regex grabs too much
in thread Regex grabs too much
If one of my special (~ ... ~) tags is found inside an HTML tag, replace that whole HTML tag with my special tag. Otherwise leave it alone.In that case the following code should do the trick:
$data =~ s/<[^<>]*?(\(~ .*? ~\))[^<>]*?>/$1/g;
That is a character-class consisting of not > or <. The perlre documentation has more details on how this works. My RE works by looking for the opening < of an HTML tag, then 0 or more non < > characters, then the special tag, then 0 or more non < > characters, then the > that closes the original HTML tag.[^<>]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Re: Regex grabs too much
by raflach (Pilgrim) on Jun 05, 2000 at 21:02 UTC | |
by Anonymous Monk on Jun 05, 2000 at 21:45 UTC | |
by mikfire (Deacon) on Jun 05, 2000 at 21:41 UTC |