Skip to main content

Text

Text utilities in one step: render a Handlebars template, split text into a list, find and replace, extract values with a regular expression, change case, and trim whitespace.

Parameters​

Which fields appear depends on the Operation.

NameShown forDefaultDescription
Operation (operation)allTemplate (Handlebars)template, split, replace, regexExtract, case, trim. Required.
Template data (data)template—The object the template reads from, e.g. {{ $nodes['Get Order'] }}.
Template (template)templateHello {{name}}!A Handlebars template. Stored verbatim — its {{ }} are Handlebars, not Blokkio expressions. Max 100,000 characters.
HTML-escape values (htmlEscape)templatefalseEscape &, <, >, quotes in inserted values. Turn on when building HTML from untrusted data.
Text (value)all except template—The text to work on.
Separator (separator)split,Used exactly as typed (spaces count). \n, \t and \r mean new line, tab and carriage return. Empty splits into single characters.
Trim parts (trimParts)splittrueTrim whitespace around each part.
Remove empty parts (removeEmpty)splittrueDrop empty parts (after trimming).
Find (search)replace—Text (or regex) to find. Empty leaves the text unchanged.
Replace with (replacement)replace—Replacement. With a regex, $1 or ${name} insert a captured group.
Find is a regular expression (useRegex)replacefalseTreat Find as a regex.
Case-sensitive (caseSensitive)replacetrueFor plain-text find only; for regex use the i flag.
Regular expression (pattern)regexExtract—The pattern, e.g. (?<user>[^@]+)@(?<domain>.+). Required.
Group (name or number, optional) (group)regexExtract—Return just this group.
Return all matches (extractAll)regexExtractfalseReturn every match instead of the first.
Regex flags (regexFlags)replace, regexExtract—Any of i (ignore case), m (multi-line ^/$), s (. matches new lines), x (ignore pattern whitespace). g is accepted and ignored — replace always replaces every match.
Case (caseType)caselower caselower, upper, title, sentence, camel, pascal, snake, kebab.

Regular expressions use .NET syntax (very close to JavaScript's; named groups are (?<name>…)) and time out after 2 seconds.

Ports​

PortDescription
main (input)The step(s) Text runs after.
output{ result }, plus matches and count for regex extract.

Output by operation​

Operationresult
TemplateThe rendered text.
SplitAn array of strings.
ReplaceThe new text.
Extract with regexThe first match (or null), or an array of all matches with Return all matches. Also returns matches (always an array) and count.
Change caseThe converted text.
TrimThe text without leading/trailing whitespace.

What a regex match returns:

  • with Group set — that group's text (null if it didn't take part);
  • else with named groups — an object of all named groups;
  • else with numbered groups — the first group;
  • else — the whole match.
{
"result": { "user": "ada", "domain": "example.com" },
"matches": [ { "user": "ada", "domain": "example.com" } ],
"count": 1
}

Case conversion examples for helloWorld-foo_bar: camel helloWorldFooBar, pascal HelloWorldFooBar, snake hello_world_foo_bar, kebab hello-world-foo-bar.

Example​

Build an order confirmation email body:

  • Operation: Template (Handlebars)
  • Template data: {{ $nodes['Get Order'] }}
  • Template:
Hi {{customer.firstName}},

Thanks for order #{{id}}. You bought:
{{#each lines}}
- {{qty}} × {{name}}
{{/each}}
{{#if note}}Note: {{note}}{{/if}}

With data { "id": 4417, "customer": { "firstName": "Ada" }, "lines": [ { "qty": 2, "name": "Mug" } ] } the result is:

Hi Ada,

Thanks for order #4417. You bought:
- 2 × Mug

Split a comma-separated tag string: Operation Split, Text {{ $trigger.body.tags }}, Separator , — "red, green, , blue" gives ["red", "green", "blue"].

Notes​

  • Handlebars built-ins such as #each, #if, #unless and #with are available.
  • Regex extract returns at most 10,000 matches.