节点 / builtin / datatransformation
Text / Formatter
Transform text: case, trim, pad, replace, split, slugify, extract, count, encode and decode
此内容尚不支持你的语言。
Clean up, reshape, search or encode a piece of text, without writing code.
What it does
Section titled “What it does”You pick an Operation and point Text at your value, for example {{ $input.title }}. The node then does one thing to that text:
- Change case: Uppercase, Lowercase, Title Case, camelCase, snake_case, kebab-case. The last three understand spaces, punctuation and existing camelCase, so
Order ID numberbecomesorder_id_number. - Shape: Trim (remove spaces at both ends), Pad, Replace, Split, Join, Slugify, Truncate, Default if empty.
- Find: Extract emails, Extract URLs, Extract numbers, Extract phone numbers return every match, not just the first.
- Count: Word count, Character count. An emoji or accented letter counts as one character.
- Encode or Decode with a Scheme: Base64, URL (whole URL), URI component, HTML entities or Hex. Accented letters and emoji survive a round trip.
Slugify turns Héllo, Wörld! into hello-world, which is handy for file names and links.
When to use it
Section titled “When to use it”- Tidy scraped text before you save or send it: trim it, fix its case, or replace a placeholder.
- Pull every email address or link out of a page’s text.
- Build a file name or link from a title with Slugify.
- Encode a value for a link with URI component, or decode Base64 text from an API.
- For patterns of your own and named fields, use Regex instead.
Inputs and settings
Section titled “Inputs and settings”22 个选项 · 选择“Operation”以查看其设置
Uppercase 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Lowercase 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Title Case 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
camelCase 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
snake_case 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
kebab-case 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Trim 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Slugify 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Extract emails 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Extract URLs 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Extract numbers 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Extract phone numbers 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Word count 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Character count 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
Pad 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
| Target Length | Number | Pad until the text reaches this many characters. 默认值:0 |
| Pad With | Text | The characters repeated to fill the space. 默认值: |
| Pad Side | Choice | Which end to pad. Options: Start, End. 默认值:Start |
Replace 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
| Find | Text | The text or pattern to look for. |
| Replace With | Text | The text put in place of each match. |
| Treat Find As Regex | Toggle | Read the Find field as a regular expression. 默认值:Off |
| Regex Flags | Text | Flags for the pattern, such as gi. 默认值:g |
Split 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
| Separator | Text | The string to split on. Empty splits into characters. 默认值:, |
Join 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
| Separator | Text | The string placed between joined items. 默认值:, |
Truncate 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
| Maximum Length | Number | Keep at most this many characters. 默认值:20 |
| Ellipsis | Text | Appended when the text is shortened. 默认值:… |
Default if empty 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
| Default Value | Text | Returned when the text is empty or only whitespace. |
Encode 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
| Scheme | Choice | Which encoding to convert to or from. Options: Base64, URL (whole URL), URI component, HTML entities, Hex. 默认值:Base64 |
Decode 的设置
| 设置项 | 类型 | 作用 |
|---|---|---|
| Text | Value | The text to transform. Bind an upstream value with {{ }}. |
| Scheme | Choice | Which encoding to convert to or from. Options: Base64, URL (whole URL), URI component, HTML entities, Hex. 默认值:Base64 |
正在显示 Uppercase 的设置
Every operation has Operation (default Uppercase) and Text. Some show extra settings:
| Operation | Extra settings |
|---|---|
| Pad | Target Length (default 0), Pad With (default a space), Pad Side (Start or End) |
| Replace | Find, Replace With, Treat Find As Regex (default off), Regex Flags (default g) |
| Split | Separator (default ,). Empty splits into single characters. |
| Join | Separator (default ,), placed between the joined entries |
| Truncate | Maximum Length (default 20), Ellipsis (default …), added only when the text is cut |
| Default if empty | Default Value, returned when the text is empty or only spaces |
| Encode, Decode | Scheme (default Base64) |
- Replace without regex replaces every occurrence of Find. With Treat Find As Regex on, the default
gflag also replaces every match; addi(gi) to ignore case. - Join expects Text to be a list, such as
{{ $input.tags }}. A single text value comes back unchanged. - URL (whole URL) leaves
:/?#&=alone, so it is safe on a full address. URI component escapes them too; use it for one value inside a link.
Outputs
Section titled “Outputs”-
Output
The field depends on the operation:
result: the new text for case, shaping, Encode and Decode operations. For Split it is a list.matches: the list of everything found by an Extract operation. It is an empty list when nothing matched.count: the number from Word count or Character count.
The output holds only that field. To keep the original data next to it, read it from the earlier node with an expression such as {{ $('HTML Extract').title }}.
Dependencies and credentials
Section titled “Dependencies and credentials”None. This node needs no connection and has no slots for other nodes.
Example workflow
Section titled “Example workflow”- Get Selected Text with Output field name
selectionreads the text you highlighted on a page. - Text / Formatter with Operation Extract emails and Text
{{ $input.selection }}. Every address comes back inmatches. - A second Text / Formatter with Operation Join, Text
{{ $input.matches }}and Separator,gives one line of addresses inresult. - A Slack node posts
{{ $input.result }}.
Common issues
Section titled “Common issues”- “Invalid base64: could not decode the input as UTF-8 text.” The text is not Base64, or it is Base64 of a file rather than text. Check that you picked the right Scheme.
- “Invalid hex: expected an even number of hex digits.” or “Invalid hex: contains non-hexadecimal characters.” The text is not a clean hex string. Remove spaces or prefixes such as
0x. - “Invalid URL encoding: malformed percent-escape sequence.” (or Invalid URI component). A
%in the text is not followed by two hex digits. Check the text was really encoded. - Replace fails with an invalid regular expression error. Treat Find As Regex is on and Find has a syntax error, or Regex Flags holds a letter that is not a flag. Turn the option off to replace plain text.
matchesis empty. Nothing in the text looks like an email, link, number or phone number. Phone numbers must be at least seven characters long and start and end with a digit; links must start withhttp://orhttps://.
Related nodes
Section titled “Related nodes”- Regex: your own patterns, with named groups as fields.
- Edit Fields: put the result back next to the other fields.
- Crypto: hashes and signatures rather than encodings.