CAPI Utils icon

CAPI Utils

Funções utilitárias de JavaScript para manipulação de JSON, arrays, strings e expressões regulares dentro do n8n.

Textos (strings)

AI-generated

Overview

This node provides utility functions for manipulating text strings within n8n workflows. It supports various string operations such as extracting values using regular expressions, replacing all occurrences of a substring, slugifying text, normalizing text by removing accents and special characters, extracting numbers, converting text to uppercase or lowercase, trimming whitespace, compacting multiple spaces, splitting text by a separator, and checking if a text contains a specific substring. This node is useful for cleaning, transforming, and analyzing text data in automation workflows, for example, extracting phone numbers from text, generating URL-friendly slugs, or filtering text content based on patterns.

Use Case Examples

  1. Extract phone numbers from a text field using a regex pattern.
  2. Replace all occurrences of a word in a text with another word.
  3. Convert product names to lowercase for consistent formatting.
  4. Split a comma-separated list of tags into an array.

Properties

Name Meaning
Guia rápido Instructions for using the node: provide input text, select the transformation, and fill in additional details as needed.
Passo 2 • O que você quer fazer com o texto? Select the string transformation operation to perform.
Passo 3 • Onde está o texto de entrada? JSON path to the input text to be transformed.
Onde salvar o texto final? JSON path where the transformed text result will be saved.
Qual padrão (Regex) usar? Regular expression pattern to use for extraction (only for 'Extrair com Regex').
Flags da Regex Optional regex flags such as 'i' for case-insensitive or 'm' for multiline (only for 'Extrair com Regex').
Qual texto procurar? Exact text to find (used in 'Substituir tudo' and 'Verificar se contém um texto').
Por qual texto substituir? Text to replace the found text with (only for 'Substituir tudo').
Qual separador utilizar? Character or text used as a separator to split the text (only for 'Dividir texto por separador').
Resultado quando não encontrar? Value to return when the text is not found; can be true, false, or custom text (only for 'Verificar se contém um texto').

Output

JSON

  • result - The transformed text or result of the string operation.

Troubleshooting

Common issue: Input text not found at the specified JSON path. Error message: 'Nenhum texto encontrado em "". Verifique a propriedade de entrada.' Solution: Verify the JSON path to the input text is correct and the data exists.

  • If using regex extraction, ensure the regex pattern is valid and properly captures groups if needed.
  • When replacing text, ensure the search text is correctly specified; empty or incorrect values may lead to no replacements.
  • For 'Verificar se contém um texto', the default return value can be customized; if unexpected boolean results occur, check this setting.

Links

Discussion