PJ-通配符大师
__token__ wildcard expansion
- 解析文本
Wildcards are the "write once, generate forever" habit that keeps resurfacing in this community - you've probably seen it as {this|that|the other} inline alternatives for batching (the old A1111 trick that most people who arrived after 2024 never learned). PJWildcardParserNode (pongjoo/ComfyUI-PJLatent, menu "PJ_Text") is the template form of that idea: you write a prompt sentence with __token__ placeholders, and each run fills every token by pulling a random line from a matching word-list file.
Example, straight from the node's own default:
一位女孩,__头发颜色__头发,穿着__衣着__,__构图__镜头,__动作__。
Every __…__ name maps to a file in the pack's wildcards/ folder (头发颜色 → 头发颜色.txt), and the parser swaps in a seeded random line from it. Change the seed, get a different outfit/angle/pose combination; keep the seed, get the identical sentence back. That's the reproducibility that makes seed-sweeps useful: batch 32 runs over a seed range and you've got a character-variation sheet with no extra typing.
The inputs:
- 提示词模板 - the full template, multiline. Supports Chinese characters in token names as well as ASCII, which matters here because the bundled word lists are Chinese-first (
发型.txt,衣着,构图…) - add your own English.txtfiles if that's not your language. - 随机种子 - seeds the whole template's rolls.
Mechanism is a clean single regex pass over __([a-zA-Z0-9_\u4e00-\u9fa5]+)__, with UTF-8 (and GBK fallback) file reads, skipping blank lines and # comments. Missing files leave the token literally in place rather than crashing. It outputs one 解析文本 string - wire it to a text encoder or into PJTextCombine for prefixing with quality tags.
One honest correction to the README. The pack advertises "嵌套与权重解析" - nesting and weight parsing. The shipped code does a single pass of token replacement: if the line a token picks happens to contain another __token__, it will not be expanded a second time, and weight syntax like (token:1.2) is passed through as literal text (which matters only if you're still on a CLIP-encoder base that respects A1111-style weights - on Flux/Qwen-era LLM encoders, weight syntax is just punctuation anyway). For a flat template with __token__ slots, it behaves exactly as advertised.
Install
Ships in pongjoo/ComfyUI-PJLatent (MIT). ComfyUI Manager → search "ComfyUI-PJLatent", or:
cd ComfyUI/custom_nodes/
git clone https://github.com/pongjoo/ComfyUI-PJLatent.git
Restart ComfyUI; no extra dependencies or downloads. It shows up as PJ-通配符大师 under "PJ_Text". This is the one of the pair to reach for when you want whole sentences composed from parts - PJWildcardNode is the simpler "roll one word from one list" sibling.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| 提示词模板 | STRING | 一位女孩,__头发颜色__头发,穿着__衣着__,__构图__镜头,__动作__。 | — |
| 随机种子 | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 解析文本 | STRING | — |