Globally replace text in several files: Difference between revisions
Globally replace text in several files (view source)
Revision as of 14:01, 2 July 2021
, 2 years agoAdded Wren
(Add Rust implementation) |
(Added Wren) |
||
Line 1,692:
Reg_Empty(#20) // Cleanup
Buf_Quit(OK)</lang>
=={{header|Wren}}==
<lang ecmascript>import "io" for File
var files = ["file1.txt", "file2.txt"]
for (file in files) {
var text = File.read(file)
System.print("%(file) contains: %(text)")
text = text.replace("Goodbye London!", "Hello New York!")
File.create(file) { |f| // overwrites existing file
f.writeBytes(text)
}
System.print("%(file) now contains: %(File.read(file))")
}</lang>
{{out}}
<pre>
file1.txt contains: "Goodbye London!"
file1.txt now contains: "Hello New York!"
file2.txt contains: "Goodbye London!"
file2.txt now contains: "Hello New York!"
</pre>
=={{header|XPL0}}==
|