uCalc API Version: 2.1.3-preview.2 Released: 6/16/2026

Warning

uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.

{@Param}

Product: 

Class: 

Remarks

Description: A replacement-only keyword used to reference a specific captured token or sub-part of a match by its numerical index.

The {@Param:n} directive is used within the replacement string of a uCalc::Transformer rule. It allows you to access individual components of a match based on their order of appearance in the pattern.

Indexing Logic

  • 0-Based Indexing: {@Param:0} refers to the first token or group matched by the pattern, {@Param:1} to the second, and so on.
  • Bounds: An out of bounds value will not cause an error, but will quietly be ignored.
  • Implicit vs. Explicit: While named variables (like {@Alpha:var}) are often preferred for clarity, {@Param} is invaluable when dealing with anonymous tokens or when the pattern consists of a sequence of similar tokens that need to be reordered.
  • Expressions: The index does not have to be a literal numeric value. It can be an expression.

Structural Reordering

One of the most powerful uses of {@Param} is for "shuffling" text. Because the replacement string can place these parameters in any order, you can easily swap the positions of words, move prefixes to suffixes, or duplicate parts of a match.

Comparison: {@Param} vs {@Self}

  • {@Self}: Returns the entire text segment matched by the pattern as a single unit.
  • {@Param:n}: Returns only the specific nth part of that segment.

Note: If a pattern uses recursion or complex grouping, the index corresponds to the flat sequence of tokens as they were validated by the engine.


Examples

1. Succinct (Quick Start: Swapping Tokens)

Identifying two consecutive words and reversing their order in the output.

New(uCalc::Transformer, t)// Match two words separated by a spacet.FromTo("{@Alpha} {@Alpha}", "{@Param:1} {@Param:0}")wl(t.Transform("Hello World"))

[Expected Output]World Hello

2. Practical (Real World: Date Format Normalizer)

Converting a date from a slash-separated format (MM/DD/YYYY) to a standardized ISO format (YYYY-MM-DD).

New(uCalc::Transformer, t)// Pattern matches: Month (0) / (1) Day (2) / (3) Year (4)t.FromTo("{@Number} / {@Number} / {@Number}", "{@Param:4}-{@Param:0}-{@Param:2}")wl(t.Transform("01/15/2026"))

[Expected Output]2026-01-15

3. Internal Test (Token Extraction)

Verifying that {@Param} can extract specific tokens from a mixed sequence while ignoring the delimiters in the final output.

New(uCalc::Transformer, t)// Pattern: Alpha (0) , (1) Number (2) ; (3)t.FromTo("{@Alpha} , {@Number} ;", "ID:{@Param:2} NAME:{@Param:0}")wl(t.Transform("User, 101;"))

[Expected Output]ID:101 NAME:User


Strategy & Critique

  • Clarity vs. Conciseness: In complex rules with 5+ tokens, {@Param:4} can become hard to track. In those cases, switching to named variables (e.g., {@Number:year}) is recommended for better code maintenance.
  • Whitespace Handling: Remember that if your pattern includes optional whitespace (like {@ws}), that whitespace occupies an index. If you forget to account for it, your {@Param} indices will be off by one.
  • Critique: The numerical approach is classic and robust, similar to regex backreferences (\1, \2), making it a low-friction tool for experienced developers.
  • See Also: Refer to Topic 817 (Pattern Methods Introduction) for an overview of other replacement keywords like {@Self} and {@Doc}.

Examples

{@Param}
				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("This {etc} big test {words:2}",
"{@Param:0}:{@Param:1}:{@Param:1+1}:{@Param:2+1}:{@Param:2*2}");
Console.WriteLine(t.Transform("This is a big test we have today"));
				
			
This:is a:big:test:we have today
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.FromTo("This {etc} big test {words:2}",
   "{@Param:0}:{@Param:1}:{@Param:1+1}:{@Param:2+1}:{@Param:2*2}");
   cout << t.Transform("This is a big test we have today") << endl;
}
				
			
This:is a:big:test:we have today
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.FromTo("This {etc} big test {words:2}",
      "{@Param:0}:{@Param:1}:{@Param:1+1}:{@Param:2+1}:{@Param:2*2}")
      Console.WriteLine(t.Transform("This is a big test we have today"))
   End Sub
End Module
				
			
This:is a:big:test:we have today