How to resolve the algorithm Globally replace text in several files step by step in the Lasso programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Globally replace text in several files step by step in the Lasso programming language
Table of Contents
Problem Statement
Replace every occurring instance of a piece of text in a group of text files with another one.
For this task we want to replace the text "Goodbye London!" with "Hello New York!" for a list of files.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Globally replace text in several files step by step in the Lasso programming language
Source code in the lasso programming language
#!/usr/bin/lasso9
local(files = array('f1.txt', 'f2.txt'))
with filename in #files
let file = file(#filename)
let content = #file -> readbytes
do {
#file -> dowithclose => {
#content -> replace('Goodbye London!', 'Hello New York!')
#file -> opentruncate
#file -> writebytes(#content)
}
}
You may also check:How to resolve the algorithm Faulhaber's formula step by step in the Mathematica / Wolfram Language programming language
You may also check:How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Visual FoxPro programming language
You may also check:How to resolve the algorithm Galton box animation step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Decorate-sort-undecorate idiom step by step in the RPL programming language
You may also check:How to resolve the algorithm Sum of squares step by step in the SQL programming language