Replace Part of Text
Verb: stuff
Available from: <Standard>
Replaces part of a text with new content based on a starting position and the number of characters set by the user.
Syntax
stuff --text(String) --startIndex(Numeric) --length(Numeric) --replacement(String) (String)=value
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--text | Text | Required | Text | Text that should have a part of it replaced by the content entered in the parameter New Content. |
--startIndex | Start index | Required | Number | Initial position of the text part that should be replaced. |
--length | Number of characters | Required | Number | Number of characters to replace, starting from the position defined in the Start Index parameter.
The value set in the Number of characters parameter must be exactly equal to the amount of characters of the part of the text that should be replaced. |
--replacement | New Content | Required | Text | New content that replaces part of the text set in the Text parameter, based on the Start index and Number of characters parameters. |
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
value | Result | Text | Text with the replacements made by adding New Content to the part defined by the Start index and Number of characters parameters. |
Example
The Replace Part of Text command replaces the word "strong" with "powerful" in the text "With RPA you will have a strong software capable of reproducing human activities." The word "strong" begins at the 41st character and ends at the 46th character.
defVar --name textToReplace --type String --value "With RPA you will have a strong software capable of reproducing human activities."
defVar --name replacedText --type String
// Replaces the word "strong" in the text with the word "powerful".
stuff --text "${textToReplace}" --startIndex 41 --length 6 --replacement powerfull replacedText=value
logMessage --message "${replacedText}" --type "Info"
// This example produces the following result:
// With RPA powerful have a strong software capable of reproducing human activities.
Remarks
The highest value that can be entered in the Start index parameter refers to the last character of the text inserted in the Text parameter.