This statement replicates the specified number of times the substrings found in the text or text fragment. In this case, inside the replicated substring, it's possible to perform the substitution of the replica number instead of the substring specified by the third parameter of this statement.
REPLICATE <ReplicaString> <ReplicasNumber> TIMES
REPLICATE <ReplicaString> <ReplicasNumber> TIMES INSIDE OF <ContextArea>
REPLICATE <ReplicaString> <ReplicasNumber> TIMES OUTSIDE OF <ContextArea>
REPLICATE <ReplicaString> <ReplicasNumber> TIMES WITH <IndexString> AS INDEX
REPLICATE <ReplicaString> <ReplicasNumber> TIMES WITH <IndexString> AS INDEX INSIDE OF <ContextArea>
REPLICATE <ReplicaString> <ReplicasNumber> TIMES WITH <IndexString> AS INDEX OUTSIDE OF <ContextArea>
Example 1
The most common use case for this statement is if you need to create multiple numbered strings from the same pattern, but also produce wildcards in the output to replace them later with the [REPLACE statement] statement. Unclear? Ok, let's look at this with an example.
REPLICATE R"\r\n.*?;" 4 TIMES WITH P"{NUM}" AS INDEX
Original text
I sure that:
{NUM}. My [Item{NUM}] is the best [Item{NUM}];
And in general - I'm the coolest.
The text after applying the statement above
I sure that:
1. My [Item1] is the best [Item1];
2. My [Item2] is the best [Item2];
3. My [Item3] is the best [Item3];
4. My [Item4] is the best [Item4];
And in general - I'm the coolest.
And now you can use the [REPLACE statement] statement to replace the [Item1] ... [Item4] substrings with what you like best about yourself and use it for affirmation ;)
Example 2
Another way to delete in the Rx language. Remove all HTML tags using the REPLICATE statement.
REPLICATE R"<[^<]*?>" 0 TIMES
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.
As you can see, we simply specified to replicate the found fragments 0 times, and this led to their removal.
Wiki: REPLACE statement
Wiki: Rx text transformation script language