🍒Text_Processor / 文本数字提取
The tiny node that pulls a number out of a caption
- 文本
- 数字提取
Every so often you need a number that's hiding inside a string - a steps count baked into a filename, a resolution in a caption, a count buried in some node's text output - and you'd rather not write a regex node to get it. Text_Processor is the KimNodes version of that two-second job: hand it text, get the text back cleaned up, plus the first integer it can find.
It's a genuinely thin utility. The whole node is maybe twenty lines. That's not a criticism - ComfyUI is full of these one-job string helpers, and they earn their place when you're stitching together a workflow where some upstream node emits "batch 3 of 12" and a downstream node wants the 12 as an INT. It's filed under the pack's Text_Tools category and there's nothing else to say about its ambition.
How it works
You feed it 输入文本 (a multiline STRING) and it does two things. First it returns the text with leading/trailing whitespace stripped - that's the 文本 STRING output. Second, if 提取数字 is on (default true), it runs a regex (\d+) over the input and returns the first number it finds as an INT on the 数字提取 output.
One thing to internalize: first number, not last, and not "all of them." If your string is "width 1024 height 768", you get 1024. If it's "frames 12 steps 30", you get 12. If there are no digits at all, you get 0 - not an error, just a zero. If you need the second number, this isn't your node.
The inputs that matter
输入文本- the string to process. Multiline, so paste away.提取数字- toggle whether the INT extraction runs. Turn it off and you just get a trimmer.
Outputs: 文本 (STRING) and 数字提取 (INT). Wire the INT into a node that takes a number - an image count, a loop count, a batch size - and you've got yourself a poor-man's string-to-int converter.
Installation
Standard KimNodes pack install - ComfyUI Manager → search "ComfyUI_KimNodes" → Install → Restart, or:
cd ComfyUI/custom_nodes && git clone https://github.com/wjl0313/ComfyUI_KimNodes
No dependencies beyond stock ComfyUI. There's nothing to configure and nothing to download.
Common issues
Honestly, this node has one failure mode and it's a behavioral one: people assume 数字提取 gives them "all the numbers" or "the last number" and get confused when it's the first. If you're trying to extract a specific field from structured text, you'd be better served by a proper text-processing node set - this is the quick-and-dirty version.
It's also worth noting the pack's whole requirement story applies: the pack's requirements.txt only lists pixeloe, and the eager import in __init__.py means if a heavier node in the pack (the YOLO ones need ultralytics) is missing its dependency, this lightweight node won't show up either. If you install the pack and see nothing in your node menu, pip install ultralytics opencv-python and restart - that unblocks everything.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| 输入文本 | STRING | 请输入文本内容 | — |
| 提取数字 | BOOLEAN | true | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 文本 | STRING | — |
| 数字提取 | INT | — |