Porovnávané verzie

Kľúč

  • Tento riadok sa pridal
  • Riadok je odstránený.
  • Formátovanie sa zmenilo.

%RxReplaceStr function




Function

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

Declaration


Blok kódu
languageesl
themeConfluence
TEXT %RxReplaceStr(
   TEXT in Text, 
   TEXT in regExp,
   TEXT	in subStr,
   INT	in from := 1,
   INT	in count := 0
 )


Parameters


textText, in which will be the replacement.
regExpRegular A regular expression, which will be replaced in the input paremeter parameter text.
substrSubstring, which will replace the found substring that matches the regular expression.
fromIndex, from which the input text is to be searched ( (0 = from start) (optional input parameter).
countNumber of occurrences to be replaced (0 = all occurrences) (optional input parameter).


Example

The function returns a string, in which will be replaced 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.

 



Blok kódu
languageesl
themeRDark
%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)