uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Description: A replacement-only keyword that represents the entire text segment captured by the pattern match.
The {@Self} keyword is used within the replacement string of a uCalc::Transformer rule. It acts as a macro for the full string of text that triggered the rule, allowing you to easily wrap or annotate existing content without manually reconstructing it using indexed parameters.
The primary use case for {@Self} is when you want to keep the matched text exactly as it is but add surrounding context. This is often called "wrapping."
{@Alpha}[{@Self}]{@Self}: The total match.{@Param:n}: Only a specific part of the match.{@Doc}: The entire source document, regardless of the match.{@Self} returns the text as it was captured before the replacement logic is applied. This makes it a reliable anchor for rules that perform complex HTML tagging or document-level annotations.
Identifying a specific keyword and wrapping it in a generic tag for later processing.
New(uCalc::Transformer, t)// Match 'Warning' and add a prefix labelt.FromTo("Warning", "!!! {@Self} !!!")wl(t.Transform("Warning: System low"))[Expected Output]!!! Warning !!!: System low
Matching a specific format (like a hex color code) and wrapping it in a span with a style attribute.
New(uCalc::Transformer, t)// Match a hex code starting with #t.FromTo("# {@Alpha:hex}", "<span style='color: {@Self}'>{@Self}</span>")wl(t.Transform("Background: #FF5500"))[Expected Output]Background: <span style='color: #FF5500'>#FF5500</span>
Verifying that {@Self} includes the literal whitespace tokens captured between pattern elements.
New(uCalc::Transformer, t)// Pattern captures: Alpha + Space + Numbert.FromTo("{@Alpha} {@Number}", "RECORD: ({@Self})")wl(t.Transform("User 123"))[Expected Output]RECORD: (User 123)
{@Self} is the most frequently used replacement keyword because it handles the "heavy lifting" of re-inserting the match without requiring the developer to track parameter indices.{@Self}, be careful about what your pattern includes. If your pattern matches optional trailing spaces, {@Self} will include those spaces, which might lead to double-spacing in the output if not intended.& in many Unix sed implementations or $0 in some regex engines, making it highly familiar to systems programmers.{@Param}) for accessing specific parts of the match.ID: 189
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("Hello World", "<{@Self}>");
Console.WriteLine(t.Transform("Hello World. HelloWorld. Hello World. Hello, World."));
<Hello World>. HelloWorld. <Hello World>. Hello, World. using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("Hello World", "<{@Self}>"); Console.WriteLine(t.Transform("Hello World. HelloWorld. Hello World. Hello, World."));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("Hello World", "<{@Self}>");
cout << t.Transform("Hello World. HelloWorld. Hello World. Hello, World.") << endl;
}
<Hello World>. HelloWorld. <Hello World>. Hello, World. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("Hello World", "<{@Self}>"); cout << t.Transform("Hello World. HelloWorld. Hello World. Hello, World.") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("Hello World", "<{@Self}>")
Console.WriteLine(t.Transform("Hello World. HelloWorld. Hello World. Hello, World."))
End Sub
End Module
<Hello World>. HelloWorld. <Hello World>. Hello, World. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("Hello World", "<{@Self}>") Console.WriteLine(t.Transform("Hello World. HelloWorld. Hello World. Hello, World.")) End Sub End Module