Skip to main content

Pattern Extractor

Pattern Extractor: pulls matches and capture groups out of text with a regular expression, without needing a Function node.

Runs pattern over text on each extract and publishes the first match, its capture groups (numbered and named), and — with Extract All on — every match. An optional group that did not participate becomes an empty string rather than a hole in the array, so downstream indexes stay stable. firstGroup is a convenience for the overwhelmingly common single-group case. A pattern that will not compile is a result, not an exception: ok becomes false, error explains, and the failure signal fires — distinct from notFound, which is a normal outcome. Note that a catastrophically backtracking pattern is still the author's problem; this runs the platform regex engine and cannot bound it.

When to use it

Extracting a value from text that is not structured data: a percentage out of a progress line, a tool name out of an agent status message, a field out of a log record. Prefer JSON Stream Parser when the payload really is JSON, and String Format or Substring for fixed-position work that needs no pattern.

At a glance

CategoryData
Type namenet.noodl.PatternExtractor
Available inbrowser, cloud
SSR compatibilitysafe
Provided bynoodl-runtime

Inputs

Values

NameTypeDefaultDescription
extractAllBooleanfalseCollects every match into Matches instead of stopping at the first one
flagsStringRegex flags i, m, s, u and y; g is controlled by Extract All and a g written here is ignored
patternStringA JavaScript regular expression without the surrounding slashes; capture groups appear on Groups
textStringThe text to search

Signals

NameTypeDefaultDescription
extractSignalRuns Pattern over Text and reports what it found

Outputs

Values

NameTypeDefaultDescription
firstGroupStringThe first capture group of the first match, which is the whole answer for a pattern like (\d+)%
groupsArrayCapture groups of the first match; an optional group that did not participate is a blank string, not a hole
matchStringThe first match, or blank when nothing matched
matchCountNumberHow many matches were found, which is at most one unless Extract All is on
matchesArrayEvery match when Extract All is on, otherwise just the first
namedGroupsObjectNamed capture groups of the first match, keyed by name

Signals

NameTypeDefaultDescription
completedSignalFires after every invocation, whatever the outcome — wire this to carry on regardless. Failure still fires and still carries its reason, so this cannot hide an error
doneSignalFires once the extract has run, whether it matched or not — Found and Not Found say which
foundSignalFires when the pattern ran and matched at least once
notFoundSignalFires when the pattern ran and matched nothing, which is an ordinary outcome rather than a mistake

Failure outputs

NameTypeDefaultDescription
errorStringWhy the pattern could not be used: it is blank, or it is not a valid regular expression
failureSignalFires when the pattern itself is unusable, which is a bug to fix rather than a result

Patterns

  • Stream text → text, pattern (\d+)%, firstGroup → Number → a progress bar.
  • Named groups turn one pattern into several outputs without chaining extractors: (?<tool>\w+)\s+(?<state>\w+).
  • failure → a visible warning during authoring catches a mistyped pattern that would otherwise read as 'never matches'.

Watch out for

  • Parsing JSON with a regex instead of using JSON Stream Parser.
  • Treating notFound as an error state — most streams contain lines the pattern is not meant to match.
  • Building a pattern from user input without bounding it; nested quantifiers can hang the frame.

Examples

Long-running task monitor: progress, batched log lines, and a visible connection

A backend job streams two kinds of frame on one connection. Pattern Extractor pulls the percentage out of human-readable status text, so a progress bar tracks it without a Function node. JSON Stream Parser turns NDJSON log payloads into values — several may complete in one frame, so values rather than parsed is what feeds downstream. Stream Buffer batches those into a flush every 250 ms, which keeps a busy log from repainting the list hundreds of times a second, and the stream's onClose flushes the tail that never reached a full batch.

Server-Sent Events, JSON Stream Parser, Substring, String Format, String Mapper

Generated

This page is generated from node-catalog-enriched.json. Do not edit it by hand — run npm run docs:nodes to regenerate, and fix the source enrichment instead.