This command replaces one string with another in the workspace . The replace command is useful for indenting blocks of text during formatting operations, among other things. The replace command only replaces plain text strings, not regular expression patterns.
replace "a" "A";
The replace command is often used for indenting generated code.
clear; get; replace "\n" "\n "; put; clear;
Replace can also be used to test if the workspace contains a particular character, in conjunction with the “(==)” tape test.
# fragment
put; replace 'x' '';
(==) {
clear; add "no 'x'"; print; clear;
}
add
add text to the workspace
lower
make workspace text lower case
upper
make workspace text upper case