Visit ComfyUI Online for ready-to-use ComfyUI environment
Extract specific text segments based on defined patterns for data extraction and text manipulation.
The ExtractSubstring
node is designed to help you extract specific portions of text from a larger string based on defined start and end patterns. This node is particularly useful when you need to isolate and work with text segments that are enclosed between specific markers or tags. By specifying a pattern, you can efficiently extract the desired substring, which can be beneficial in various text processing tasks, such as data extraction, text analysis, or content manipulation. The node simplifies the process of identifying and retrieving text between markers, making it an essential tool for managing and organizing textual data.
The input_string
parameter is the main text from which you want to extract a substring. It supports multiline input, allowing you to work with extensive text blocks. The content of this parameter directly influences the node's output, as it serves as the source from which the substring is extracted. The default value is an empty string, and there are no specific minimum or maximum length constraints, but the effectiveness of the extraction depends on the presence of the specified pattern within this text.
The pattern
parameter defines the markers or tags that indicate the start and end of the substring you wish to extract. It consists of two parts separated by a pipe (|
) character, where the first part is the start marker and the second part is the end marker. If the end marker is not specified, the node defaults to using a newline character as the end marker. The default pattern is "标签始|标签尾", which means the node will look for text between these two markers. The choice of pattern directly affects the extraction process, as it determines which part of the input_string
will be isolated.
The output of the ExtractSubstring
node is a single string that contains the extracted text segment. This output represents the portion of the input_string
that lies between the specified start and end markers. If the markers are not found, or if an error occurs during extraction, the output will be an empty string. The extracted substring is returned as a single string, which can then be used for further processing or analysis in your workflow.
pattern
you specify accurately reflects the markers present in your input_string
to achieve the desired extraction results.input_string
, leading to an unsuccessful extraction attempt.pattern
accurately matches the markers in your input_string
. Adjust the pattern to ensure it corresponds to the actual text markers present in the input.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.