ComfyUI > Nodes > D2 Nodes ComfyUI > D2 Regex Switcher

ComfyUI Node: D2 Regex Switcher

Class Name

D2 Regex Switcher

Category
D2
Author
da2el-ai (Account age: 713days)
Extension
D2 Nodes ComfyUI
Latest Updated
2025-05-04
Github Stars
0.03K

How to Install D2 Nodes ComfyUI

Install this extension via the ComfyUI Manager by searching for D2 Nodes ComfyUI
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter D2 Nodes ComfyUI in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

D2 Regex Switcher Description

Versatile node for text pattern search using regular expressions, automating text manipulation for AI artists.

D2 Regex Switcher:

The D2 Regex Switcher is a versatile node designed to search for patterns within a given text using regular expressions and then concatenate and output the results. This node is particularly useful for AI artists who need to dynamically manipulate and format text based on specific patterns or keywords. By leveraging the power of regular expressions, the D2 Regex Switcher allows you to define complex search criteria and corresponding outputs, making it an essential tool for text processing tasks where precision and flexibility are required. Its primary goal is to streamline the process of text manipulation by automating the matching and formatting of text based on user-defined rules, thus enhancing productivity and creativity in text-based projects.

D2 Regex Switcher Input Parameters:

text

This parameter represents the text that you want to search through using regular expressions. It is a required input and can be a multiline string, allowing you to work with large blocks of text. The default value is an empty string, and it is crucial for determining the context in which the regular expressions will be applied.

regex_and_output

This parameter is a multiline string that contains pairs of regular expressions and their corresponding output text, separated by --. It defines the patterns to search for and the text to output when a match is found. The default value is "pony\n--\nscore_9,\n--\n--\nhighres, high quality,", which serves as an example of how to structure the input. This parameter is essential for specifying the rules that the node will use to process the input text.

pre_delim

This parameter allows you to specify a delimiter to be added before the matched text in the output. The options are "Comma", "Line break", and "None", with no default value specified. This setting helps in formatting the output text by adding a desired separator before the matched content.

suf_delim

Similar to pre_delim, this parameter specifies a delimiter to be added after the matched text in the output. The options are the same: "Comma", "Line break", and "None". This parameter is useful for ensuring that the output text is formatted according to your needs by appending a separator after the matched content.

show_text

This parameter determines whether the original text should be displayed in the output. It accepts "True" or "False" as options, with "True" as the default value. This setting is helpful for debugging or for when you need to see the original text alongside the processed output.

text_check

This optional parameter is a multiline string used for input verification. It allows you to provide additional text for checking purposes, ensuring that the input text meets certain criteria before processing. This can be useful for validating the input text format or content.

prefix

This optional parameter allows you to specify a string to be added at the beginning of the output text. It is a multiline string with a default value of an empty string. This parameter is useful for adding a consistent starting text to all outputs, which can be helpful for labeling or categorizing the results.

suffix

This optional parameter allows you to specify a string to be added at the end of the output text. Like prefix, it is a multiline string with a default value of an empty string. This parameter is useful for appending a consistent ending text to all outputs, which can be helpful for labeling or categorizing the results.

D2 Regex Switcher Output Parameters:

combined_text

This output parameter is a string that contains the final concatenated text after applying the regular expressions and formatting rules. It includes the matched text, along with any specified prefixes, suffixes, and delimiters. This output is the primary result of the node's processing and is used for further text manipulation or display.

prefix

This output parameter returns the prefix string that was added to the beginning of the combined_text. It is useful for verifying that the correct prefix was applied during the text processing.

suffix

This output parameter returns the suffix string that was added to the end of the combined_text. It is useful for verifying that the correct suffix was applied during the text processing.

index

This output parameter is an integer that indicates the index of the matched regular expression pattern within the regex_and_output list. It is useful for understanding which pattern was matched and can be used for debugging or further processing logic.

D2 Regex Switcher Usage Tips:

  • To effectively use the D2 Regex Switcher, ensure that your regex_and_output parameter is well-structured with clear and precise regular expressions. This will help in accurately matching the desired patterns in your text.
  • Utilize the prefix and suffix parameters to add context or labels to your output, making it easier to categorize or identify the results in larger projects.
  • Experiment with different delimiters using the pre_delim and suf_delim parameters to achieve the desired formatting for your output text, especially when preparing text for presentation or further processing.

D2 Regex Switcher Common Errors and Solutions:

Regex error in tag

  • Explanation: This error occurs when there is a syntax issue in one of the regular expressions provided in the regex_and_output parameter.
  • Solution: Review the regular expressions for any syntax errors or unsupported patterns. Ensure that each regular expression is correctly formatted and test them individually to verify their correctness.

Error during tag replacement

  • Explanation: This error indicates a problem occurred while replacing text based on the regular expressions, possibly due to an invalid pattern or unexpected input.
  • Solution: Check the regex_and_output parameter for any incorrect or unsupported patterns. Ensure that the input text is in the expected format and that the regular expressions are designed to handle the input correctly.

D2 Regex Switcher Related Nodes

Go back to the extension to check out more related nodes.
D2 Nodes ComfyUI
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Playground, enabling artists to harness the latest AI tools to create incredible art.