I’m trying to write a script to switch two lines in a file, and for some
reason am having difficulty grokking it.
I have an ugly start, which I’ll post if you want, but it’s over thirty
lines long and still doesn’t work. I’m sure there is a very short, very
simple, very Ruby solution to this, and I’m sure one of you has it.
Oh, sorry, I should have mentioned, I’m providing two regexes, and the
script is to replace a line that matches one regex with a line that
matches the other.
I.E.
line one
line two
line three
a=/one/
b=/three/
And the script produces:
line three
line two
line one
I intend on passing it robust enough regexes that they only match a
single line (i.e. not /line/).