Skip to main content

$$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​

ArgumentTypeValuesRequired / Default ValueDescription
PrimarystringYes
findstringYesValue to search in input string (depends on type, if set to REGEX, should be a regular expression)
replacementstring""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)
typeenumSTRING/ FIRST/REGEX/REGEX-FIRSTSTRINGMatching type
frominteger0At 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"