Initializing help system before first use

fregreplace

Purpose
Apply regex replacements to all lines of a file.
Synopsis
procedure fregreplace(src:text, dst:text, a_args:...)
Arguments
src 
Source file.
dst 
Destination file (can be the same as src).
a_args 
Replacement commands.
Example
Replacing all occurrences of 'minimise' by 'Minimize' and 'maximise' by 'Maximize' and output the result to a new file.
 public declarations
   F=`
Running minimise is not the same as maximise
`
 end-declarations
 fcopy("text:F","myfile.txt")
 fregreplace("myfile.txt", "mynewfile.txt", "/minimise/Minimize/",
             "/maximise/Maximize/")
   ! -> REGREPL myfile.txt mynewfile.txt /minimise/Minimize/ /maximise/Maximize/
 cat("myfile.txt","")
   ! -> CAT myfile.txt
   ! Output:  Running minimise is not the same as maximise
 cat("mynewfile.txt","")
   ! -> CAT mynewfile.txt
   ! Output:  Running Minimize is not the same as Maximize
Further information
1. Each replacement command is of the form "SpSrSo" where S is a symbol used as the separator in the string, p a regular expression to select the pattern to replace, r the replacement text and o any options. The supported options are o (apply replacement once only per line), O (apply replacement only once on the entire file), i (case insensitive comparisons), p (print line only if a matching was found) and e (extended regular expressions). For instance the string ":red:blue:io" will replace the first occurrence in every line of the selected file of the sequence "red" by "blue" independently of the case.
2. The actual replacement operation relies on the regreplace routine.
3. This procedure behaves like cp if no replacement command is given.
4. Execution of the program terminates if the operation fails and exitonfail is true.

© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.