Visit ComfyUI Online for ready-to-use ComfyUI environment
Extract specific patterns from text using regular expressions for data parsing and manipulation.
The RegexExtract
node is designed to help you extract specific patterns from a given string using regular expressions, a powerful tool for pattern matching. This node is particularly useful when you need to isolate or retrieve specific parts of text data, such as extracting email addresses, phone numbers, or any other pattern-based information from a larger body of text. By leveraging the capabilities of regular expressions, the RegexExtract
node allows you to perform complex text extraction tasks with ease, making it an essential tool for data parsing and text manipulation. Whether you're working with structured or unstructured data, this node provides a flexible and efficient way to extract the information you need.
This parameter represents the input text from which you want to extract patterns. It can be a single line or multiline string, depending on the nature of your data. The content of this parameter is crucial as it serves as the source from which the regular expression will search for matches.
The regex_pattern
parameter is a string that defines the regular expression pattern you want to use for extraction. This pattern dictates what the node will look for in the input string. Regular expressions are highly versatile, allowing you to specify complex search criteria using a combination of literals, metacharacters, and quantifiers.
This parameter determines the extraction mode, which can be "First Match," "All Matches," "First Group," or "All Groups." Each mode specifies a different way of extracting data: "First Match" retrieves the first occurrence of the pattern, "All Matches" retrieves all occurrences, "First Group" extracts the first capturing group from the first match, and "All Groups" extracts a specific group from all matches.
A boolean parameter that, when set to True
, makes the regular expression search case-insensitive, meaning it will ignore the case of the characters in the input string. The default value is True
, which is useful when you want to ensure that the search is not affected by the case of the text.
This boolean parameter, when set to True
, allows the ^
and $
anchors in the regular expression to match the start and end of each line within the input string, rather than just the start and end of the entire string. The default value is False
.
When this boolean parameter is set to True
, the dot (.
) in the regular expression will match any character, including newline characters. This is useful when you want to match patterns that span multiple lines. The default value is False
.
This parameter is an integer that specifies which capturing group to extract when using the "First Group" or "All Groups" modes. It allows you to target specific parts of the matched pattern, providing more granular control over the extraction process.
The result
parameter contains the extracted text based on the specified mode and regular expression pattern. If the mode is "First Match," it will return the first occurrence of the pattern. For "All Matches," it returns all occurrences, joined by a newline. In "First Group" mode, it returns the specified capturing group from the first match, and in "All Groups" mode, it returns the specified group from all matches, also joined by a newline. If no matches are found, the result will be an empty string.
multiline
parameter to ensure that line boundaries are correctly interpreted by the regular expression.dotall
parameter to True
to allow the dot (.
) to match newline characters.group_index
parameter to extract specific parts of a match, especially when dealing with complex patterns that include multiple capturing groups.regex_pattern
contains syntax errors or unsupported constructs.group_index
specified does not exist in the matched pattern.group_index
corresponds to an existing capturing group in your regular expression. Adjust the index based on the number of groups in your pattern.regex_pattern
is correctly defined and matches the intended parts of the input string. Consider adjusting the pattern or enabling case_insensitive
if case sensitivity is an issue.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.