Porovnávané verzie
porovnané s
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 the specified regular expression, by another substring.
Declaration
Blok kódu | ||||
---|---|---|---|---|
| ||||
INT %RxReplaceStr( TEXT in Text, TEXT in regExp, TEXT in subStr, INT in from := 01, INT in count := 0 ) |
Parameters
text | Text, in which will be replacement. |
regExp | Regular expression, which will be replaced in the input paremeter text. |
substr | Substring, which will replace the found substring that mathes the regular expression. |
from | Index, from where to search input text (0 = from start) (optional input parameter). |
count | Number 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.
Blok kódu | ||||
---|---|---|---|---|
| ||||
%RxReplaceStr("text some text", "[a-z]+", "(X)") ;returns text: (X) (X) (X) %RxReplaceStr("text some text", "[a-z]+", "(X)", 01, 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) |