re.match (Regex Match)
Check whether a string starts with your pattern (and the difference from search, settled)
- flags
- match
re.match answers a very specific question: does this string start with my pattern? OvumReMatch is the ComfyUI version of that, and it's the node to reach for when you're validating prefixes - checking that a filename begins with a run prefix, that a prompt opens with a quality tag, that a path starts with the right directory. If you need the pattern anywhere in the string, that's the pack's re.search node instead; the two are the classic regex mix-up, and knowing which one you grabbed is half the battle.
How it works
Give it pattern and string, and it runs re.match() over each input - anchoring at index 0. Return a RE_MATCH object (or None if the start doesn't match). It also has pos and endpos inputs, which let you start the anchor check partway through the string: set pos to 5 and it checks whether the pattern matches from index 5. That's a subtle power move if you're parsing a fixed-width header where the interesting data begins after a known offset.
The useful inputs:
pattern- multiline field for the regex.string- the text to check.string_in- optional link that overrides the widget; accepts a string or a list of strings, processed element-wise. Batch your "does every filename start with this" checks in one go.flags- RE_FLAGS from the pack's re.compile flags node (default IGNORECASE on).pos/endpos- start/end index bounds, both min 0.
The match output is list-shaped (one entry per input string, None for misses) and feeds straight into re.Match.group, re.Match.span, or re.MatchView. The status readout in the node shows "Matched" / "No match", or "Matched 2/5" on lists, so you can see the result before you even wire anything downstream.
Why you'd reach for it
Prefix validation is a real workflow gate: confirming an output filename starts with the expected project tag before downstream nodes touch it, checking a seed line starts with digits, verifying a caption begins with a quality marker. Because it never raises on a miss (you just get None in the list), it's safe to wire into a branch node and let a downstream conditional decide what happens on a failed check.
Installing it
OvumReMatch ships in comfy-ovum. Install through ComfyUI Manager (search "comfy-ovum") or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart ComfyUI and it shows up under ovum/regex. No model downloads, no heavy deps - Manager installs the pack's small requirements automatically.
The gotcha
The name invites confusion with re.search, and the difference genuinely bites: match anchors to the start, search doesn't. A common failure is watching OvumReMatch return "No match" for a string that clearly contains the pattern - because it does contain it, just not at position zero. If that's you, swap in re.search. And remember the default IGNORECASE is on here too, which is usually what you want for prefix checks but worth knowing when it isn't.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| pattern | STRING | The regular expression pattern. | |
| string | STRING | The string to search. Used if `string_in` is not connected. | |
| string_inopt | STRING | Input string or list of strings. Overrides `string` widget if connected. | |
| flagsopt | RE_FLAGS | 2 | Regex compilation flags. |
| posopt | INT | 0 | The starting index for the match. |
| endposopt | INT | 0 | The ending index for the match. If 0, searches to the end of the string. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| match | RE_MATCH | — |