How to resolve the algorithm Globally replace text in several files step by step in the Red 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 Red 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 Red programming language

Source code in the red programming language

>> f: request-file
>> str: read f
>> replace/all str "Goodbye London!" "Hello New York!"
>> write f str


  

You may also check:How to resolve the algorithm Probabilistic choice step by step in the Sidef programming language
You may also check:How to resolve the algorithm Roots of a quadratic function step by step in the Delphi programming language
You may also check:How to resolve the algorithm Pernicious numbers step by step in the Factor programming language
You may also check:How to resolve the algorithm Append a record to the end of a text file step by step in the MATLAB / Octave programming language
You may also check:How to resolve the algorithm Partition an integer x into n primes step by step in the PARI/GP programming language