Text Search
Does this text contain it? Count, find, or pull the matching lines
- result
TextSearch answers the simplest family of questions about a string: does it contain this? How many times? Where? Which lines have it? It's the lightweight scout of the wwdm-aicd pack - less power than TxtReg's regex, but for plain-substring questions it's faster to set up and impossible to get the regex wrong.
The mode dropdown has five answers. contains returns "true" or "false" as a string. count returns how many times the substring appears. find_first gives the character position of the first hit, or -1 if there's none - that's the one you'd feed into a slice or a check. find_all returns every position where it appears. find_lines splits the text on newlines and returns every line containing the search term - which overlaps with what TextFilterLines does, but where that node is a filter (and lets you invert with grep_v), this one is a "give me the matching lines" grab.
The inputs are text, search_for, mode, and an ignore_case toggle. If the text is empty or search_for is empty, the node returns a sensible default - "false" for contains, "0" for count, "-1" for find_first, an empty list for the list-ish modes - so it never errors on empty input. One detail from the source worth flagging: find_all and find_lines return multiple values, so they behave like a list even though the node's declared output type is a single STRING. In practice, wire it to a node that accepts a list and it works; just don't expect find_all's result to look like one flat string.
Mechanically it's plain str.find loops and str.count - no regex at all, and with ignore_case it just lowercases both sides before searching. That means search_for with a . or * in it is treated literally, which is exactly why people reach for this over regex for a quick "is the word 'error' in here" check.
Install, standard for the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/wwsmiao/comfyui-wwdm-aicd.git
Restart ComfyUI, find it under wwdm-aicd. No dependencies beyond stdlib; no requirements.txt in the repo despite what the README's install section says. README and code comments are in Chinese; widget labels are English.
The natural pairing: contains feeds TextJudge-style logic, find_first feeds TextSubstring for cutting around a found position, and find_lines hands a list straight to ListOps. If you need case-insensitive pattern matching or extracting around the hit, TxtReg is the upgrade path - but for the plain "is it there / how many" questions, this node is the one you'll grab because it's over in three seconds.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| search_for | STRING | — | |
| mode | COMBO | contains | 5 options: contains, count, find_first, find_all, find_lines |
| ignore_caseopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | STRING | — |