JayBee has asked for the wisdom of the Perl Monks concerning the following question:
I'm not sure if the $last string matches right after the the $first string, but let's just say that it does and there's only one in the entire $string for now, but additional ways to do this would be a bonus for future use.
Thank you in advance for all your help.
So just to be clear, how can I get the substitution operator to replace everything in my tag with a another tag such as a comment?my $string='foo bar foo bar <span id="box1" class="box1"> foo bar foo bar </span> foo bar'; $first='<span id="box1'; $last='/span>'; $reserve='<!-- BOX1 -->'; $string =~ s/$first(.*?)$last/$reserve/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replacing everything in between using s///;
by merlyn (Sage) on May 09, 2005 at 01:20 UTC | |
|
Re: Replacing everything in between using s///;
by tlm (Prior) on May 09, 2005 at 01:28 UTC | |
by JayBee (Scribe) on May 09, 2005 at 10:32 UTC | |
|
Re: Replacing everything in between using s///;
by ikegami (Patriarch) on May 09, 2005 at 03:08 UTC | |
|
Re: Replacing everything in between using s///;
by eibwen (Friar) on May 09, 2005 at 01:30 UTC | |
|
Re: Replacing everything in between using s///;
by TedPride (Priest) on May 09, 2005 at 03:45 UTC | |
by tlm (Prior) on May 09, 2005 at 04:58 UTC |