Workflow and ServiceDesk Community

 View Only

Replace String In Text 

Jun 13, 2012 09:46 AM

Component definition

This component finds all instances of a given sequence of characters in a given string and replaces them with a different sequence of strings. For example, all of the commas followed by spaces in the following string "a, b, c,d" could be changed to just commas giving us "a,b,c,d". NOTE: the "Replace Text" and "Replace With" strings do not need to be the same length.

Component icon

text_rich.png

Definition of component input value or values

Configuration
Input Value Name Input Value Data Type Req'd Example Format Explanation
Input Variable Name String Yes UserTag This is a variable holding the string through which to search for the sequence of characters in "Replace Text".
Replace Text String Yes ", " This is a string holding the sequence of characters to find in the input variable. This string need not be the same length as the "Replace With" string. This may be a process variable, a constant value, a dynamic value or the output from an embedded dynamic model.
Replace With String Yes UserTag This is a string holding the sequence of characters to insert in place of the characters from "Replace Text". This string need not be the same length as the "Replace Text" string. This may be a process variable, a constant value, a dynamic value or the output from an embedded dynamic model.
Output Variable Name String Yes TrimmedTag This is the name of the variable that will receive a copy of the string in "Input Variable Name" with all instances of the string in "Replace Text" replaced with the string in "Replace With". It may often be the same variable specified in "Input Variable Name".

Definition of component output value or values

A variable with the name specified in "Output Variable Name" containing a copy of the string in "Input Variable Name" with all instances of the string in "Replace Text" replaced with the string in "Replace With".

Connection information

None

Component settings

None

Use case

Separate tags into separate values.

One way to use this component would be for processing list that entries where the delimiter is more than one character. For example, if parsing some HTML to get the options from a select tag we could replace all instances of "</option><option>" with a single character and then apply the "Split Text Into Collection" component to get the individual options using "~" as the delimiter. To Do this the parameters would be setup as follows:

  • Input Variable Name: HTMLSelect
  • Replace Text: "</option><option>"
  •  
  • Output Variable Name: HTMLSelect

In this case, because the original value is of no further use to us, we can simply use the same variable to hold the result.

[Example 2]

[Describe the use case. Insert screen shots or package files. Insert a description of how the settings are configured. Insert additional information about the use case that you are submitting.]

Statistics
0 Favorited
1 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Related Entries and Links

No Related Resource entered.