This statement replaces with the target string all substrings in the text or text fragment that match the specified Rx string. And, for sure, you will use this statement most often.
REPLACE <FindString> TO <ReplaceString>
REPLACE <FindString> TO <ReplaceString> INSIDE OF <ContextArea>
REPLACE <FindString> TO <ReplaceString> OUTSIDE OF <ContextArea>
Example 1
Replace the CR and LF characters to an HTML line break (<br />)
REPLACE B"\r\n" TO P"<br />"
Original text
The first row of text.
The second row.
And a little more text.
The text after applying the statement above
The first row of text.<br />The second row.<br />And a little more text.
Example 2
And now - remove all HTML tags from the text. To do this, we need to specify the desired tags using a regular expression. And by the way, this is one of the three possible ways in the Rx language to remove something from the text.
REPLACE R"<[^<]*?>" TO P""
Original text
<p>The <b>text</p> example with <i>HTML</i> tags.</p>
The text after applying the statement above
The text example with HTML tags.
Example 3
And finally, let's slightly tweak the text we got in the previous example so that its meaning matches its essence.
REPLACE P"with" TO P"without"
Original text
The text example with HTML tags.
The text after applying the statement above
The text example without HTML tags.
Wiki: REPLICATE statement
Wiki: Rx text transformation script language