2024-11-24 14:06:18 +01:00
2024-11-24 14:06:18 +01:00
2024-11-24 14:06:18 +01:00
2024-11-22 00:16:28 +01:00
2024-11-22 00:16:28 +01:00
2024-11-22 00:16:28 +01:00
2024-11-24 14:06:18 +01:00

ComfyUI - String Utils

Collection of custom nodes for ComfyUI dedicated to the analysis and transformation of text strings, such as for formatting and conversions between types.

Nodes

Text Formatter

Several nodes with varying numbers of optional inputs that can be used in conjunction with a formatting string to create the output. The node uses standard python string formatting.

The nodes are useful to compose prompts based on variable inputs and can be combined with dynamic prompts for even more flexibility.

Example

Insert values into a string.

Format

"Hello, {arg0}! Did you know? {arg1} is the answer to everything."

Input

arg0: "John"
arg1: 42

Output

"Hello, John! Did you know? 42 is the answer to everything."

Replace Text

Replaces a string in a text with something else, using either plain text replacement or regular expressions (regex).

Example 1

Replace a word in a text.

Input

text: "Hello, John!"
replace: "John"
replacement: "Mr. Smith"

Output

"Hello, Mr. Smith!"

Example 2

Replace a pattern in a text using regex and use a captured part in the replacement.

Input

text: "Hello, John! Did you know 42 is the answer to everything?"
replace: "([0-9]+) is"
replacement: "\1 is in fact"

Output

"Hello, John! Did you know 42 is in fact the answer to everything?"

ATOI/ITOA

Two simple nodes to convert strings to integers and vice versa.

Python Text Script

A node that takes a number of inputs as well as a Python script that takes the given arguments to produce a result. Intended as a brute- force method in cases where a general purpose formatter might not cut it and no dedicated node is available. The value assigned to the result variable inside the script will be returned by the node.

Example

Return a description based on a numeric input.

Script

age = int(arg0)

if age < 13:
    result = "a nice child"
elif age < 22:
    result = "an angsty teenager"
else:
    result = "a mature adult"

Input

arg0: 17

Onput

"an angsty teenager"
S
Description
No description provided
Readme
54 KiB
Languages
Python 100%