Files
da2el-ai-D2-nodes-ComfyUI/docs/en/node_text.md
T
2025-03-25 04:10:50 +09:00

4.1 KiB

English | 日本語 | 繁体中文

Node

🍅 Text Node

D2 Regex Replace

  • Can replace using regular expressions
  • Multiple conditions can be specified
  • Supports reuse of regex match strings (e.g., \1, \2)
  • Target string can be specified by "tag unit" or "whole"

Input

  • text
    • Target string for search
  • mode
    • Tag: Break down text by newlines and "," and replace individually
    • Advanced: Replace text as a whole
  • regex_and_output
    • List of search strings and output strings
    • Write in following format
    • If output string is empty, matched part is deleted
    • No limit on number of entries
Search string 1
--
Output string 1
--
Search string 2
--
Output string 2

Output

  • text
    • Text after replacement

Sample

Sample for removing Pony series quality tags.

Mode: Tag

Input text

score_9, score_8_up, (score_7_up, score_6_up:0.8) , rating_explicit, source_anime, BREAK
1girl, swimsuit

Regex Replace

.*(score_|rating_|source_).*
--
--
BREAK
--

Output text

1girl, swimsuit

D2 Regex Switcher

  • Searches input text with regex and outputs matching text
  • Main purpose is switching quality tags per Checkpoint
  • When matching string is found in input text, outputs target string and match index (starting from 0)
  • Can concatenate strings at front and back

Input

  • text
    • Search target string
  • prefix
    • String to concatenate at front
  • suffix
    • String to concatenate at back
  • regex_and_output
    • List of search strings and output strings
    • Write in following format
  • pre_delim
    • Character inserted between prefix and regex_and_output
    • Comma: , / Line break: newline / None: nothing
  • suf_delim
    • Character inserted between regex_and_output and suffix

Output

  • combined_text
    • String combining prefix + output string + suffix
  • prefix / suffix
    • Input passthrough

D2 Multi Output

  • Node that outputs generic parameters like seed and cfg as lists

Input

  • type
    • FLOAT: Floating point numbers. For CFG etc.
    • INT: Integers. For steps etc.
    • STRING: Strings. For sampler etc.
    • SEED: Can input seed values with random number button
  • Add Random
    • Adds random numbers to input field
    • Only shown when type is SEED

D2 Filename Template

  • A node for creating filenames
  • Can incorporate external elements

Input

  • arg_1 arg_2 arg_3
    • Import values from other nodes
  • format
    • %date:{yyyy/MM/dd/hh/mm/ss}%
      • yyyy: Year
      • MM: Month
      • dd: Day
      • hh: Hour
      • mm: Minute
      • ss: Second
    • %node:{id}.{key}%
      • Retrieves values by specifying node ID and item name
      • Example: %node:8.width%: Get width from node ID 8
    • %arg_1% (same for 2 and 3)
      • Embed input values
    • %arg_1:ckpt_name% (same for 2 and 3)
      • Embed checkpoint name with .safetensors removed

Example

%date:yyyyMMdd-hhmmss%_%arg_1:ckpt_name%
👇
20241219-021926_obsessionIllustrious_v31

D2 Delete Comment

  • Deletes comments from text
  • Targets line-beginning "#", line-beginning "//", and anything between "/*" and "*/"

About the Comment Shortcut Key

  • Comment shortcut key (ctrl + /) is available in all text boxes
  • The shortcut key can be changed in Settings > D2 > shortcutKey
  • To disable it, delete the above content