RxReplaceStr

RxReplaceStr

%RxReplaceStr function


 

 

Function

The function replaces the predefined number of substrings in the input text, that match the specified regular expression, with another substring.

Declaration

TEXT %RxReplaceStr( TEXT in Text, TEXT in regExp, TEXT in subStr, INT in from := 1, INT in count := 0 )

Parameters

text

Text, in which will be the replacement.

regExp

A regular expression, which will be replaced in the input parameter text.

substr

Substring, which will replace the found substring that matches the regular expression.

from

Index, from which the input text is to be searched ( (0 = from start) (optional input parameter).

count

Number of occurrences to be replaced (0 = all occurrences) (optional input parameter).

Example

The function returns a string, in which count occurrences of regular expression regExp will be replaced by substring substr, while input text will be searched from the index from. If some of the input parameters is invalid, the function returns an undefined value.

 

%RxReplaceStr("text some text", "[a-z]+", "(X)") ;returns text: (X) (X) (X) %RxReplaceStr("text some text", "[a-z]+", "(X)", 1, 0) ;returns text: (X) (X) (X) %RxReplaceStr("text some text", "[a-z]+", "(X)", 1, 2) ;returns text: (X) (X) text %RxReplaceStr("text some text", "[a-z]+", "(X)", 2, 1) ;returns text: t(X) some text %RxReplaceStr("text some text", "[a-z]+", "(X)", 5, 1) ;returns text: text (X) text %RxReplaceStr("text some text", "[a-z]+", "(X)", 20, 0) ;returns text: text some text %RxReplaceStr("text some text", "[a-z]+", "(X)", 0, 20) ;returns text: (X) (X) (X)

Comments