Regexp: str1-anything but str2-str2 => str1-str2

A simple question about whether this can be done with regular
expressions in Ruby:

str = <<EOS
start

between1

between2

between3

between4

end
EOS
re = /what here?!/
puts str.gsub(re, ‘----------------- zapped -------------------’)

Can re be written so the output is similar to:

start
between1
between2
between3
between4
end

I tried the following, but no luck:
re = / and replace anything in between, but regexps are
just sweet, so I was still trying with them.

On Dec 8, 10:21 am, wx [email protected] wrote:

between1

between2
Any other simple way? The next thing I will do is find and replace anything in between, but regexps are
just sweet, so I was still trying with them.

A non-greedy regex (.*? in this case) makes this pretty easy:

str.gsub(/.*?</script>/m, ‘’).gsub(/\n+/, “\n”)

yermej,

Thanks, that worked wonderfully!