Connectors / Helper / Text Helper

Text manipulation utilities such as splitting, upper casing and truncating (updated: 1579179800310)

Text Helper

Manipulate text using common utilities such as splitting, upper casing and truncating

Overview

The Text Helper connector allows you to manipulate text results from connectors and triggers, primarily to extract and format information so that it can be passed to a connector in a suitable format.

'Concatenate' Example

The following screenshot shows a text helper which is using the concatenate function to pull the 'email address' and 'suggestion' fields from the form trigger and feed it in to the first Slack connector:

text-helper-form-slack

This will result in john@example.com has suggested: this is my suggestion being sent to the first Slack connector, which can use the $.steps.text-helpers-1.result variable:

slack-connector-helper-variable

The 'Contains' operation

The Contains operation is useful for checking if a keyword is contained in a piece of text being returned by another connector.

It is however limited to only one word or phrase. Please see the example on our Useful scripts page for instructions on how to check for multiple keywords or phrases.

Using 'Regular Expressions'

'Replace' Example 1: Replace characters in phone number

This example will use regular expressions within the Replace operation to demonstrate the power of this way of generating the pattern. For instance, when dealing with phone numbers some systems don't allow special characters, apart from the + in the prefix. Taking the example of US phone numbers, which are formatted as '+1 (564) 654-5464'. We cannot simply use the Remove special characters operation in the Text Helper, as this will remove all special characters, leaving '15646545464'. Instead, we use a 'Regular Expression' pattern in the Replace operation to remove just the characters of interest. By setting the Pattern to [()\s-] and the Replacement to an empty string, we can remove just the characters we need to remove:

text-helpers-replace-1

The output of this operation is

{
"result": "+15646545464"
}

Note you can explore more regular expression examples at this website: https://javascript.info/regular-expressions. You will notice that the regular expression flags are explicit options in the input panel in Tray. For instance, the Replace all patterns? field toggles the g flag on the expression, and the Case sensitive? field toggles the i flag.

'Replace' Example 2: Remove empty fields from a text body

Take another example. In this example, we have a body of text which has been populated with the values that come from a random record. Let's say this formatted body of text is as follows:

First Name: Example
Last Name:
Email: example@email.com

Ideally, we want to remove any empty fields, such as the Last Name field, which have no value. This can be achieved very easily by using the Text Helper's Replace operation, using a regular expression pattern. By specifying the pattern ([^:\\n]+): *\\n, we can target any line that starts with a label (any text preceding a colon), that has no value after this colon. By specifying the Replacement value as an empty string, we can transform the above body of text into:

First Name: Example
Email: example@email.com
text-helpers-replace-2

All Operations

Latest version:

3.0

Base64 Encoder/Decoder

Base64 encode/decode a specified value.

Change type

Change the type of a value.

Concatenate

Concatenate a list of texts, using a separator if provided.

Contains

Check if text contains a particular pattern.

Escape characters

Escape characters from a string, specified in the input.

Extract URLs

Extract all of the URLs from a given piece of text, returning them as a list.

Extract all by Regular Expression

Extract a list of matches when a regular expression is applied to a given text.

Extract by Regular Expression

Extract the first match when a regular expression is applied to a given text.

Format currency

Format currency to the specified denomination.

Generate unique name

Given the name of an object (e.g. an account), and a list of one or more existing object names, generate a unique name by appending "(n)" on the end of the name.

Get domain from URL

Given a website URL, extract the full website domain.

Get domain from email address

Given a user's email address, extract the website domain.

Get first middle last name

Given a user's full name, extract their first, middle and last name.

Get text after

Given a string and a pattern, this operation will return the substring between where the pattern was found depending on the match number and beginning of the string.

Get text before

Given a string and a pattern, this operation will return the substring between the beginning of the string and where the pattern was found depending on the match number.

Get text between

Extract the text between a start and an end pattern, searching in a longer piece of text.

Get text length

Get the length of a string.

Hex Encoder/Decoder

Hex encode/decode a specified string.

Is URL?

Check if a string is a valid URL.

Is domain?

Check if a string is a valid domain.

Is email?

Check if a string is a valid email address.

Is generic domain?

Check if a website domain is a "generic" domain, such as gmail.com or hotmail.com.

Is numeric?

Check if a text string is a number.

Lower case

Convert a string to lower case.

Match

Retrieve the result of matching a string against a regular expression.

Parse URL

Parse a URL string to get each of the core components of the URL (path, query string, etc...).

Parse email

Parse out an email address (such as "Name <name@domain.com>") into its component parts such as name and domain.

Parse email list

Parse out a list of email addresses (such as "Name <name@domain.com>") into component parts such as name and domain.

Proper case

Upper case the first character of every word in the text passed.

Regular expression match test

Checks if a piece of text matches a regular expression. Returns true if it matches, false otherwise.

Remove characters

Remove character(s) from a given string.

Remove special characters

Remove all non-alpha numeric characters (including spaces) from a string.

Replace

Replace a pattern in a text string with something else.

Select first n characters

Select the first n characters from a string.

Select last n characters

Select the last n characters from a string.

Sentence case

Convert a string to sentence case.

Shorten

Shorten text to a maximum allowed length.

Split

Split text by a character into an list of words.

Strip HTML Tags

Strip all HTML tags from the input text leaving only the tag's text content

Trim whitespace

Returns the specified string with the leading and trailing spaces removed.

Typecast

Typecast a specified value.

URL encode key/value pairs

URL encode a specified set of key/value pairs. Strings only.

URL encode/decode

URL encode/decode a specified string.

Underscore

Convert some text to "snake case", lowercasing all text, removing special characters, and replacing spaces with underscores.

Upper case

Convert a string to upper case.