%RxReplaceStr function




Function

The function replaces the predefined number of substrings in the input text, that are matching the specified regular expression, by another substring.

Declaration
INT %RxReplaceStr(
   TEXT in Text, 
   TEXT in regExp,
   TEXT	in subStr,
   INT	in from := 1,
   INT	in count := 0
 )
Parameters
textText, in which will be replacement.
regExpRegular expression, which will be replaced in the input paremeter text.
substrSubstring, which will replace the found substring that mathes the regular expression.
fromIndex, from where to search input text (0 = from start) (optional input parameter).
countNumber of occurrences to be replaced (0 = all occurrences) (optional input parameter).
Example

The function returns string, in which will be replaced count occurrences of regular expression regExp by substring substr, while input text will be searched from index from. If some of the input parameters is invalid, the function returns 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)

0 komentárov

Nie ste prihlásený. Akékoľvek zmeny, ktoré vykonáte, sa označia ako anonymné. Ak už máte svoj účet, pravdepodobne sa budete chcieť prihlásiť .