Canonical regex semantic feature

Conditional replacement expansion

Selects replacement text according to capture participation or value.

Semantic feature ID
feature.replacement-conditional
Feature class
replacement

Meaning and scope

Selects replacement text according to capture participation or value.

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

Corpus shorthand

<replacement-conditional>

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
PCRE2 syntax summaryreplacement syntax or api<replacement-conditional>

Prerequisites, modifiers, and interactions

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

Operations, captures, and replacement

Relevant operations

  • replace firstoperation.replace-firstReplace the first applicable match.
  • replace alloperation.replace-allReplace all matches under the host advancement rule.
  • replace callbackoperation.replace-callbackCompute replacement text from a match callback.
  • expand replacementoperation.expand-replacementExpand a replacement template against existing match data.

Capture and result behavior

Conditional replacement expansion reads capture or assertion state to resolve matching but does not allocate a capture merely by making that reference.

Replacement implications

Conditional replacement expansion directly changes replacement expansion, copied subject text, callback output, or replacement progress: Selects replacement text according to capture participation or value.

Text model, diagnostics, and resources

Unicode and text model

Once the profile's text domain is fixed, Conditional replacement expansion introduces no additional Unicode, normalization, or encoding rule.

Errors and diagnostics

Conditional replacement expansion has no feature-specific diagnostic class; ordinary syntax, unsupported, and operation errors remain separately observable.

Resource and termination behavior

Conditional replacement expansion adds no independent resource limit or termination state beyond the containing operation.

Examples and edge-case concepts

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

Positive
Demonstrate that Selects replacement text according to capture participation or value. using the smallest source-documented manifestation and a bound operation/profile.
Negative
Separate unsupported or syntactically rejected Conditional replacement expansion from an accepted pattern that produces no match.
Edge
Vary the material dimensions for Conditional replacement expansion: definition, capture_result, replacement, host_operation; keep unrelated syntax and host state fixed.

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.

  • PCRE2 syntax summaryPCRE2 · retrieved at cutoff · official implementation documentationsyntax and replacement manifestationspcre2-syntax

Corpus binding

Semantic ID feature.replacement-conditional, 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