in reply to Replacing everything in between using s///;
Well, if you add /s to what you have, everything between and including $first and $last will be replaced. You say this didn't work for you?
Here's a useful mnemonic to remember the difference between /s and /m:
/s affects the meaning of a single regexp character (namely "."), while /m affects the meaning of multiple regexp characters (actually, just two: "^" and "$").It's just a mnemonic, not the full story, but it comes in handy. With /m in effect, "^" matches not only the beginning of the string, but also the beginning of any line of text contained in the string (i.e. right after any embedded newlines). Likewise, with /m, $ will match the end of every line contained in the string, i.e. just before every newline contained in the string (though if the last character of the string is not a newline, then "$" matches the very end of the string). On the other hand, /s only makes "." match newlines too.
BTW, the parentheses in your regexp are superfluous, since you are not doing anything with the captured string, and in this case they are not needed for grouping either.
But despite my giving you these pointers on your regexp, I agree with merlyn that regexps are not the tool for this kind of problem.
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Replacing everything in between using s///;
by JayBee (Scribe) on May 09, 2005 at 10:32 UTC |