Regex replace on a file

I want to do a simple regex replace on a file. I want to replace this
multiline match

[\\S\\s]*?

with this string:

How can I do this with ruby assuming my file is: /html/page.html

2007/10/23, eggie5 [email protected]:

I want to do a simple regex replace on a file. I want to replace this
multiline match

[\\S\\s]*?

with this string:

How can I do this with ruby assuming my file is: /html/page.html

Please show us what you have already.

Kind regards

robert

Hi,

Am Dienstag, 23. Okt 2007, 16:50:04 +0900 schrieb eggie5:

I want to do a simple regex replace on a file. I want to replace this
multiline match

As far as I see for multilines the -i option doesn’t work.
You could do something like

whole = File.read “fname”
whole.gsub! /…/m, “…”
File.open “fname.mod” do |f| f.write whole end

Sorry, but I suppose the best tool for this task is Vim.

Bertram

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs