Regex replace on a file

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

<!--scripts-->[\\S\\s]*?<!--endscripts-->

with this string:

<script type="text/javascript" src="/path/to/javascript.js"></script>

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

Please show us what you have already.

Kind regards

robert

···

2007/10/23, eggie5 <eggie5@gmail.com>:

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

<!--scripts-->[\\S\\s]*?<!--endscripts-->

with this string:

<script type="text/javascript" src="/path/to/javascript.js"></script>

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

Hi,

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

···

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

--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de