From 8d317c49fa51db661c32f282514d10ed079fd029 Mon Sep 17 00:00:00 2001 From: Patrick Kasteel Date: Fri, 2 Jan 2026 18:53:51 +0000 Subject: [PATCH] Initial commit: Substring Extractor for ComfyUI --- __init__.py | 3 +++ substring_extractor.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 __init__.py create mode 100644 substring_extractor.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..47e32d8 --- /dev/null +++ b/__init__.py @@ -0,0 +1,3 @@ +from .substring_extractor import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS + +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] \ No newline at end of file diff --git a/substring_extractor.py b/substring_extractor.py new file mode 100644 index 0000000..295f863 --- /dev/null +++ b/substring_extractor.py @@ -0,0 +1,33 @@ +class SubstringExtractor: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "text": ("STRING", {"multiline": True, "default": ""}), + "begin_delimiter": ("STRING", {"default": "Begin Eyes;"}), + "end_delimiter": ("STRING", {"default": "End Eyes;"}), + }, + } + + RETURN_TYPES = ("STRING",) + FUNCTION = "extract" + CATEGORY = "TextParsing" + + def extract(self, text, begin_delimiter, end_delimiter): + try: + start_index = text.find(begin_delimiter) + if start_index == -1: + return (f"Start delimiter not found",) + + start_pos = start_index + len(begin_delimiter) + end_index = text.find(end_delimiter, start_pos) + + if end_index == -1: + return (f"End delimiter not found",) + + return (text[start_pos:end_index].strip(),) + except: + return ("Error during extraction",) + +NODE_CLASS_MAPPINGS = {"SubstringExtractor": SubstringExtractor} +NODE_DISPLAY_NAME_MAPPINGS = {"SubstringExtractor": "🔍 Substring Extractor"} \ No newline at end of file