Canonical regex semantic feature

Typed capture result shape

Makes capture structure, alternation optionality, repetition and transformations part of the host-visible regex output type.

Semantic feature ID
feature.typed-capture-result-shape
Feature class
result

Meaning and scope

Makes capture structure, alternation optionality, repetition and transformations part of the host-visible regex output type.

Corpus class: result. The claim scope is canonical-invariant.

Corpus shorthand

Regex<Output>

This is an abstract corpus form for discussing the semantic shape. It is not universal regex syntax.

Names and semantic variants

The corpus records no separate aliases or historical names.

No separate semantic variants are declared for this feature.

Syntax and API manifestations

Manifestations are source-specific ways this semantic feature becomes visible. They demonstrate provenance and vocabulary; they are not a universal spelling or a compatibility claim.

SourceKindForm
Swift Regex type overviewsyntax or apiRegex<Output>

Prerequisites, modifiers, and interactions

The corpus records no separate typed feature interaction for this identity.

Operations, captures, and replacement

Relevant operations

  • compileoperation.compileCompile or validate a pattern without requiring a successful match.
  • extractoperation.extractReturn a whole-match or selected-capture value.
  • find alloperation.find-allEnumerate non-overlapping matches under the host advancement rule.
  • replace callbackoperation.replace-callbackCompute replacement text from a match callback.

Capture and result behavior

The feature changes the static or dynamic result shape as a function of capture structure, optionality, repetition and transformations.

Replacement implications

Replacement callbacks may consume typed captures, while template replacement remains a separate replacement-dialect contract.

Text model, diagnostics, and resources

Unicode and text model

Typed output may transform substrings, but underlying match ranges retain the profile's native string-index semantics.

Errors and diagnostics

A statically inferred shape can reject an ill-typed use at build time; dynamic construction instead reports runtime parsing or cast outcomes.

Resource and termination behavior

Result materialization cost follows the produced capture/output structure and is not a match-complexity guarantee.

Examples and edge-case concepts

These are semantic test concepts, not claims about the syntax or support of a particular implementation.

  • Distinguish Typed capture result shape from its nearest existing construct.
  • Probe source-defined acceptance and rejection boundaries for Regex<Output>.
  • Preserve native result spans and attributable diagnostics.

Authoritative source references

The semantic identity and documented behavior are bound to the following exact corpus source records. Normative publishers remain authoritative for their own standards; the Regex Conformance corpus owns the reviewed cross-source semantic model.

  • Swift Regex Builder DSLSwift Evolution · SE-0351 · normative standardBuilder composition and capture/output transformationswift-regex-builder
  • Swift regex literalsSwift Evolution · SE-0354 · normative standardBuild-time parsing and inferred Regex output typesswift-regex-literals
  • Swift Regex type overviewSwift Evolution · SE-0350 · normative standardTyped capture output, optionality and dynamic AnyRegexOutputswift-regex-type

Corpus binding

Semantic ID feature.typed-capture-result-shape, feature revision 4, corpus status frozen declared cutoff semantic universe, discovery cutoff 2026-09-08T00:14:25Z.

Snapshot: semantic-corpus/snapshots/regex-semantic-features-2026-09-08.v4.json
Revision: 3285cc9fa8310df0af00fa50724d65531e0695d9
Semantic digest: e2c99c582ad9c8f2875060f9cb9d3ec0da8057f554ac09477f8e07b96da30b05