String manipulation methods reference
String manipulation activities overview
Workflow designer provides a set of string manipulation activities grouped together on the Palette, in the String Utils section.
The following screenshot shows the String Utils workflow activities and a simple example of a workflow in which one of these activities is used:
This topic provides a full reference of the available string manipulation elements:
- Index Of
- Last Index Of
- Insert
- Json Parser
- Length
- Matches
- Replace
- Replace All
- Substring
- To Upper Case
- To Lower Case
- Epoch To String
- Format Date Time
Index Of
Returns the first index within a search string in a specified text.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Text | Required | String | Input text. |
Search Characters | Required | String | String to search for. | |
Start Position | Optional | Integer | Start position of the text to search from. | |
Output | Output | Not applicable | Integer | The first index within the Search Characters string found in the Text string starting from the position specified by the Start Position value. Returns -1 if the specified search characters are not found in the text. |
Last Index Of
Returns the last index within a search string in a specified text.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Text | Required | String | Input text. |
Search Characters | Required | String | String to search for. | |
Start Position | Optional | Integer | Start position of the text to search from. | |
Output | Output | Not applicable | Integer | The last index within the Search Characters string found in the Text string starting from the position specified by the Start Position value. Returns -1 if no match is found. |
Insert
Inserts a string in a specified text.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Text | Required | String | Input text. |
Offset | Optional | Integer | The distance between the beginning of the text and a string to be inserted. The offset argument must be greater than or equal to 0, and less than or equal to the length of the sequence. | |
Insertion | Required | String | Text to insert. | |
Output | Output | Not applicable | String | The text with inserted string. |
Json Parser
Retrieves a string from a specified Json.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Json | Required | Array | Json string. |
Path For Search | Required | String | A path from the Json string to retrieve. For information about syntax for this field, see JsonPath syntax . | |
Limit | Optional | Integer | 1 is the default value. | |
Output | Output | Not applicable | String | Retrieves the specified string from the Json. |
For an example workflow, see Using-the-Json-Parser-string-manipulation-method-to-retrieve-information.
Length
Counts the character length of a specified text.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Text | Required | String | Input string text. |
Output | Output | Not applicable | Integer | A count of characters in a specified input string. |
Matches
Attempts to match the input string against a regular expression, instead of finding a subsequent match. The regular expression follows the rules of Java regular expressions.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Text | Required | String | Input text. |
Regexp | Required | String | Regular expression to match the input text. | |
Output | Output | Not applicable | Integer | Returns 1 if true, and 0 if false. |
Replace
Replaces all occurrences of a string within another string.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Text | Required | String | Text to search and replace in. The text string can be empty. |
Search Text | Required | String | Search string to search for. | |
Replacement | Required | String | String to replace it with. | |
Output | Output | Not applicable | String | The text with replacements. |
Replace All
Replaces every substring of a text string that matches the given regular expression with the given replacement.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Text | Required | String | The text to modify. |
Regexp | Required | String | Regular expression matching the text to be replaced. | |
Replacement | Required | String | Replacement string to be substituted for each match. | |
Output | Output | Not applicable | String | The text with any processed replacements. |
Substring
Retrieves a substring from a specified text.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Text | Required | String | Text to search in. |
Start Position | Optional | Integer | The position to start from. A negative start position can be used to start characters from the end of the string. | |
End Position | Optional | Integer | The position to end at. | |
Output | Output | Not applicable | String | A string between a specified start position and end position retrieved from the input text. |
To Upper Case
Converts input text string to uppercase text.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Text | Required | String | Input text. |
Output | Output | Not applicable | String | Converted text. |
To Lower Case
Converts input text string to lowercase text.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Text | Required | String | Input text. |
Output | Output | Not applicable | String | Converted text. |
Epoch To String
Converts the epoch/UNIX timestamp to a formatted date.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Epoch In Seconds | Required | Integer | The epoch/UNIX timestamp. For example, 1572385070 |
Time Zone | Optional | String | The timezone of the output. For example, America/Vancouver, Europe/Berlin, Asia/Qatar If a value is not specified, the output will use the UTC time zone. | |
Datetime Format | Optional | String | The date and time format of the output. Use the Java date format. For example, "EEE, MMM d, ''yy"—Wed, Jul 4, '01 If a format is not specified, the M-dd-yy format is used (for example, November-22-19). | |
Output | Output | Not applicable | String | The epoch timestamp in string format. For example, 1572385070 is converted to November-22-19 |
Format Date Time
Converts an input date and time string to new formatted date and time.
Parameter type | Parameter name | Required | Data type | Description |
---|---|---|---|---|
Input | Date Time | Required | String | Date and time input to convert. |
Input Time Zone | Optional | String | The timezone of the input. If input has timezone, this will be ignored. Defaults to UTC time zone. | |
Input Date Format | Optional | String | The date and time format of the input. Used for parsing input with a custom date format. Defaults to the standard ISO 8601 date formats. | |
Output Time Zone | Optional | String | The timezone of the output. | |
Output Date Format | Optional | String | The date and time format of the output. | |
Locale | Optional | String | Locale of the output. Defaults to en_US locale. | |
Output | Output | Not applicable | String | The newly formatted date and time with the timezone offset. |
Example:
Parameter type | Parameter name | |
---|---|---|
Input | Date Time | 2042-09-24T12:15:00-0500 |
Input Time Zone | null | |
Input Date Format | null | |
Output Time Zone | -08:00 | |
Output Date Format | MM-dd-yyyy hh:mm a | |
Locale | null | |
Output | Output | 09-24-2042 09:15 AM |
Example: Workflow that uses the Json Parser activity
The following example shows how the Json Parser method is used in a workflow.
The Send HTTP Request activity sends its Json output to the Json Parser activity. The Json Parser activity searches for the Json string that the Json Path defines, and sends no more than three returned Json strings (the limit defined in the Limit parameter) to the Send In App notification activity.
You can save
that uses this workflow, export it to your environment, and see how it works.Required licensing
SaaS subscribers who use BMC Helix ITSM or BMC-Helix-Virtual-Agent-Basic-service are entitled to this feature.