$$replace
Search and replaces a substring in the given input
Usage​
{
"$$replace": /* undefined */,
"find": /* string */,
"replacement": "" /* string */,
"type": "STRING" /* or FIRST / REGEX / REGEX-FIRST */,
"from": 0 /* integer */
}
"$$replace(<find>,[replacement],[type],[from]):{input}"
note
Concrete values in the usage example are default values.
Returns​
string
Arguments​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | string | Yes | ||
find | string | Yes | Value to search in input string (depends on type , if set to REGEX , should be a regular expression) | |
replacement | string | "" | Value to replace each match (or only first if type is REGEX-FIRST ), when using regular expression can use group matches (e.g. $1 ) (Note: to escape $ if starting with it) | |
type | enum | STRING / FIRST /REGEX /REGEX-FIRST | STRING | Matching type |
from | integer | 0 | At what index in the string the search should start from |
Examples​
Input
Definition
Output
"hello"
"$$replace:$"
"hello"
"hello"
"$$replace(l):$"
"heo"
"hello"
"$$replace(l,x):$"
"hexxo"
"hello"
"$$replace(l,x,FIRST):$"
"hexlo"
"hello"
"$$replace(l,x,FIRST,3):$"
"helxo"
"hello"
"$$replace([le],x,REGEX):$"
"hxxxo"
"hello"
"$$replace([le],x,REGEX,2):$"
"hexxo"
"hello"
"$$replace([le],x,REGEX-FIRST):$"
"hxllo"
"hello"
"$$replace([le],x,REGEX-FIRST,2):$"
"hexlo"