String Replace
Description
This port is being used to replace a part of a string.
App Builder Object
Source Code
function execute() {
if (context.search === undefined) { context.search = inPorts[1].value === undefined ? '' : inPorts[1].value; }
if (context.replace === undefined) { context.replace = inPorts[2].value === undefined ? '' : inPorts[2].value; }
switch (trigger) {
case 1:
context.search = inPorts[1].value;
break;
case 2:
context.replace = inPorts[2].value;
break;
default: break;
}
if (inPorts[0].value) {
return [inPorts[0].value.replace(new RegExp(context.search, 'g'), context.replace)];
}
return [];
}
In Ports
Position | Name | Message Type | Description |
---|---|---|---|
1 | Input String | String | This port is being used to receive the string from which something should be replaced of. |
2 | Search Value | String | This port is being used to define the search value for which will be searched in the Input String (In Port 1). |
3 | New Value | String | This port is being used to define the new value which will be applied to each found section in the Input String (In Port 1) of the Search Value (In Port 2). |
Out Ports
Position | Name | Message Type | Description |
---|---|---|---|
1 | New String | String | This port is being used to send out the message containing the searched and replaced string. |
Properties
Name | Description |
---|---|
Object Name | The name of the object on the canvas. |
Show Code View | The switch to turn on code view for the Code Object. |
Duplicate code into custom Code Object |