Replace Text

Verb: replaceText

Replaces all occurrences of terms, snippets, or regular expressions found in text with new content.

Syntax

replaceText --texttoparse(String) [--useregex(Boolean)] --pattern(String) [--regexOptions(DisplayableRegexOptions)] --textpattern(String) [--replacement(String)] (String)=value

Inputs

Script Designer Required AcceptedTypes Description
--texttoparse Text to Parse Required Text Text to have occurrences replaced.
--useregex Use Regular Expression Optional Boolean When enabled, performs the search in Text to Parse using a regular expression.
--pattern Regular Expression Only whenUse Regular Expression is True Text Regular expression used to find the excerpt(s) of the text to be replaced.
--regexOptions Regular Expression Options Optional DisplayableRegexOptions Filtering options that assist in regular expression search:
  • Compiled
  • Culture Invariant
  • ECMA Script
  • Explicit Capture
  • Ignore Case
  • Ignore Pattern Whitespace
  • Multiline
  • Right To Left
  • Singleline

  • More than one filtering option is accepted in this parameter.
    --textpattern Text to Find Only whenUse Regular Expression is False Text Term or snippet that should be found and replaced in Text to Parse.
    --replacement Replace With Optional Text New term or phrase that should replace all occurrences found in Text to Parse.
    --texttofind Text to find(Obsolete) Optional Text Text that should be found on the Text to Parse to substitute.
    This parameter is obsolete, use the Text to Find parameter instead.
    --ignorecase Ignore case(Obsolete) Optional Boolean When enabled, specifies case-insensitive matching.
    This parameter is obsolete. To select regular expression options, use the Regular Expression Options instead.
    --activateescapesequences Use escape sequences(Obsolete) Optional Boolean When enabled, allows using special escape characters.
    This parameter is obsolete. To select regular expression options, use the Regular Expression Options instead.

    Outputs

    Script Designer AcceptedTypes Description
    value Changed Text Text Text with all replacements by new content made.

    Example

    Example 1: The Replace Text command is used to replace the term "wgd" with "IBM" in all instances of the text.

    defVar --name textToReplace --type String --value "wgd Automation"
    defVar --name textToFind --type String --value wgd
    defVar --name newText --type String --value IBM
    defVar --name changedText --type String
    // Replaces the term "wgd" within the text "wgd Automation" with "IBM".
    replaceText --texttoparse "${textToReplace}" --textpattern "${textToFind}" --replacement "${newText}" changedText=value
    logMessage --message "${changedText}" --type "Info"
    // This example produces the following output: IBM Robotic Process Automation.
    

    Example 2: The Replace Text command is used to replace all occurrences of the text via the regular expression "\d\d\d\d\d-\d\d\d", for" 15055-480 ".

    defVar --name textToReplace --type String --value "IBM Robotic Process Automation - Rio Preto: 04730-090"
    defVar --name newContent --type String --value "15055-480"
    defVar --name regularExpression --type String
    defVar --name changedText --type String
    setVar --name "${regularExpression}" --value "\\d\\d\\d\\d\\d-\\d\\d\\d"
    logMessage --message "Text before replacement: ${textToReplace}" --type "Info"
    // Replace all occurrences of the regular expression "\\d\\d\\d\\d\\d-\\d\\d\\d" by "15055-480".
    replaceText --texttoparse "${textToReplace}" --useregex  --pattern "${regularExpression}" --regexOptions "RightToLeft" --replacement "${newContent}" changedText=value
    logMessage --message "Text after replacement: ${changedText}" --type "Info"
    // This example produces the following result:
    // Text before replacement: IBM Robotic Process Automation - Rio Preto: 04730-090
    // Text after replacement: IBM Robotic Process Automation - Rio Preto: 15055-480
    

    See Also

  • Add Escape Characters to Regular Expression
  • Add Escape Characters to Text
  • Calculate Hash
  • Change Text Case
  • Check File
  • Concatenate Texts
  • Convert HTML to Text
  • Count Occurrences in Text
  • Count Text Characters
  • Create Random Text
  • Create Table By Regular Expression
  • Empty or Null Text Variable
  • Find by Regular Expression
  • Find Occurrences in Text
  • Format Text
  • Get Subtext
  • Get Text from Regular Expression
  • HTML to Markdown
  • Insert New Line to Text
  • Join Text
  • Pad Text
  • Parse URI
  • Remove Diacritics
  • Remove Escape Characters
  • Replace Part of Text
  • Split Text
  • Trim Text Blanks