Phased rollout This version of the software is currently available only to early adopter SaaS customers as the first step in our phased rollout.

String manipulation methods reference


This topic describes workflow elements that can be used to manipulate string input and pass the manipulated string output to another element in a workflow. 

While several elements are available in the palette, additional functions are available in the expression builder. BMC recommends using functions in expressions to maintain simple process designs. For more information, see Using-functions-to-build-custom-expressions

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:  

StringManipActivities.png

This topic provides a full reference of the available string manipulation elements:

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.

Click here to view examples of output...

(null, *)          = -1

(*, null)          = -1

("", "")           = 0

("", *)            = -1 (except when * = "")

("aabaabaa", "a")  = 0

("aabaabaa", "b")  = 2

("aabaabaa", "ab") = 1

("aabaabaa", "")   = 0

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.

Click here to view examples of output...

(null, *, *)          = -1

(*, null, *)          = -1

("aabaabaa", "a", 8)  = 7

("aabaabaa", "b", 8)  = 5

("aabaabaa", "ab", 8) = 4

("aabaabaa", "b", 9)  = 5

("aabaabaa", "b", -1) = -1

("aabaabaa", "a", 0)  = 0

("aabaabaa", "b", 0)  = -1

("aabaabaa", "b", 1)  = -1

("aabaabaa", "b", 2)  = 2

("aabaabaa", "ba", 2)  = -1

("aabaabaa", "ba", 2)  = 2

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.

Click here to view examples of output...

(null, *, *)       = null

("any", null, *)   = "any"

("any", *, null)   = "any"

("", "", "zzz")    = "zzz"

("", ".*", "zzz")  = "zzz"

("", ".+", "zzz")  = ""

("abc", "", "ZZ")  = "ZZaZZbZZcZZ"

("<__>\n<__>", "<.*>", "z")      = "z\nz"

("<__>\n<__>", "(?s)<.*>", "z")  = "z"

("ABCabc123", "[a-z]", "_")       = "ABC___123"

("ABCabc123", "[^A-Z0-9]+", "_")  = "ABC_123"

("ABCabc123", "[^A-Z0-9]+", "")   = "ABC123"

("Lorem ipsum  dolor   sit", "( +)([a-z]+)", "_$2")  = "Lorem_ipsum_dolor_sit"

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.

Click here to view examples of output...

(null, *)   = null

("", *)     = ""

("abc", 0)  = "abc"

("abc", 2)  = "c"

("abc", 4)  = ""

("abc", -2) = "bc"

("abc", -4) = "abc"

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.

JsonParserActivity.png

Click here to view JSON of this workflow.

Failed to execute the [code] macro.

You can save a copy of a service 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.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*