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.
uCalc patterns are constructed using two fundamental building blocks: Anchors and Variables. While effective patterns often combine both to define structure and capture data, a valid pattern may consist of only anchors, only variables, or a mixture of both.
Code: {val}, the text Code: serves as the anchor. A pattern like Error consists solely of an anchor.Code: actually represents two distinct anchors: Code and :. Unless WhitespaceSensitive is explicitly enabled, Code: will match both Code: and Code : equally.{...}.Code: {val}, the variable {val} captures the dynamic content immediately following the anchors.{mytoken:1} captures exactly one token of any kind, while {groupA:2}{groupB:3} captures 2 tokens followed by 3 tokens._token_newline or redefining them).Escaping Characters:Because { and } are reserved for variable definitions, if you need to match them as literal anchors, you must enclose them in single quotes.
func '{' {body} '}' (Matches func { ... })func { {body} } (This does not generate a syntax error, but it fails to capture literal braces. Instead, it interprets the inner structure as a variable definition or nested expression, leading to unexpected matching behavior.)Code:\s*(?<val>.*). In uCalc, it is simply Code: {val}.Split(':') relies on array indices (parts[1]). uCalc Variables preserve context and allow you to access data by Name (e.g., referencing {val} in replacements or callbacks) rather than fragile numeric indices.ID: 193
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("is {etc} see", "({@Self})");
Console.WriteLine(t.Transform("This is a test to see how anchors/variables work"));
This (is a test to see) how anchors/variables work using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("is {etc} see", "({@Self})"); Console.WriteLine(t.Transform("This is a test to see how anchors/variables work"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("is {etc} see", "({@Self})");
cout << t.Transform("This is a test to see how anchors/variables work") << endl;
}
This (is a test to see) how anchors/variables work #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("is {etc} see", "({@Self})"); cout << t.Transform("This is a test to see how anchors/variables work") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("is {etc} see", "({@Self})")
Console.WriteLine(t.Transform("This is a test to see how anchors/variables work"))
End Sub
End Module
This (is a test to see) how anchors/variables work Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("is {etc} see", "({@Self})") Console.WriteLine(t.Transform("This is a test to see how anchors/variables work")) End Sub End Module
ID: 194
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
// Variables are {etc} and {ch}
// Anchors are "This", either "a small" or "an easy", and "Test"
t.FromTo("This {etc} {ch: a small | an easy } Test", "<{etc}> ({ch}) experiment");
Console.WriteLine(t.Transform("This is such an easy test."));
<is such> (an easy) experiment. using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // Variables are {etc} and {ch} // Anchors are "This", either "a small" or "an easy", and "Test" t.FromTo("This {etc} {ch: a small | an easy } Test", "<{etc}> ({ch}) experiment"); Console.WriteLine(t.Transform("This is such an easy test."));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
// Variables are {etc} and {ch}
// Anchors are "This", either "a small" or "an easy", and "Test"
t.FromTo("This {etc} {ch: a small | an easy } Test", "<{etc}> ({ch}) experiment");
cout << t.Transform("This is such an easy test.") << endl;
}
<is such> (an easy) experiment. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); // Variables are {etc} and {ch} // Anchors are "This", either "a small" or "an easy", and "Test" t.FromTo("This {etc} {ch: a small | an easy } Test", "<{etc}> ({ch}) experiment"); cout << t.Transform("This is such an easy test.") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
'// Variables are {etc} and {ch}
'// Anchors are "This", either "a small" or "an easy", and "Test"
t.FromTo("This {etc} {ch: a small | an easy } Test", "<{etc}> ({ch}) experiment")
Console.WriteLine(t.Transform("This is such an easy test."))
End Sub
End Module
<is such> (an easy) experiment. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() '// Variables are {etc} and {ch} '// Anchors are "This", either "a small" or "an easy", and "Test" t.FromTo("This {etc} {ch: a small | an easy } Test", "<{etc}> ({ch}) experiment") Console.WriteLine(t.Transform("This is such an easy test.")) End Sub End Module
ID: 199
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
// When a variable is used multiple times in a pattern,
// such as {tag} in this case, the matching text must be the same
t.FromTo("<{tag}> {words:2} {more} {tag}>",
"tag={tag}, 2 words={words}, text={more}");
Console.WriteLine(t.Transform("abc xyz more wordsbold").Text);
tag=div, 2 words=abc xyz, text=more words<b>bold</b> using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // When a variable is used multiple times in a pattern, // such as {tag} in this case, the matching text must be the same t.FromTo("<{tag}> {words:2} {more} </{tag}>", "tag={tag}, 2 words={words}, text={more}"); Console.WriteLine(t.Transform("<div>abc xyz more words<b>bold</b></div>").Text);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
// When a variable is used multiple times in a pattern,
// such as {tag} in this case, the matching text must be the same
t.FromTo("<{tag}> {words:2} {more} {tag}>",
"tag={tag}, 2 words={words}, text={more}");
cout << t.Transform("abc xyz more wordsbold").Text() << endl;
}
tag=div, 2 words=abc xyz, text=more words<b>bold</b> #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); // When a variable is used multiple times in a pattern, // such as {tag} in this case, the matching text must be the same t.FromTo("<{tag}> {words:2} {more} </{tag}>", "tag={tag}, 2 words={words}, text={more}"); cout << t.Transform("<div>abc xyz more words<b>bold</b></div>").Text() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
'// When a variable is used multiple times in a pattern,
'// such as {tag} in this case, the matching text must be the same
t.FromTo("<{tag}> {words:2} {more} {tag}>",
"tag={tag}, 2 words={words}, text={more}")
Console.WriteLine(t.Transform("abc xyz more wordsbold").Text)
End Sub
End Module
tag=div, 2 words=abc xyz, text=more words<b>bold</b> Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() '// When a variable is used multiple times in a pattern, '// such as {tag} in this case, the matching text must be the same t.FromTo("<{tag}> {words:2} {more} </{tag}>", "tag={tag}, 2 words={words}, text={more}") Console.WriteLine(t.Transform("<div>abc xyz more words<b>bold</b></div>").Text) End Sub End Module
ID: 230
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
// "ID" and ":" are Anchors. "{id}" is the Variable.
t.FromTo("ID: {id}", "Found ID: {id}");
Console.WriteLine(t.Transform("ID: 12345").Text);
Found ID: 12345 using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // "ID" and ":" are Anchors. "{id}" is the Variable. t.FromTo("ID: {id}", "Found ID: {id}"); Console.WriteLine(t.Transform("ID: 12345").Text);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
// "ID" and ":" are Anchors. "{id}" is the Variable.
t.FromTo("ID: {id}", "Found ID: {id}");
cout << t.Transform("ID: 12345").Text() << endl;
}
Found ID: 12345 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); // "ID" and ":" are Anchors. "{id}" is the Variable. t.FromTo("ID: {id}", "Found ID: {id}"); cout << t.Transform("ID: 12345").Text() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
'// "ID" and ":" are Anchors. "{id}" is the Variable.
t.FromTo("ID: {id}", "Found ID: {id}")
Console.WriteLine(t.Transform("ID: 12345").Text)
End Sub
End Module
Found ID: 12345 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() '// "ID" and ":" are Anchors. "{id}" is the Variable. t.FromTo("ID: {id}", "Found ID: {id}") Console.WriteLine(t.Transform("ID: 12345").Text) End Sub End Module
ID: 231
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
// Anchors: "Server", "=", ";", "Database"
// Variables: {srv}, {db}
t.FromTo("Server={srv};Database={db};",
"Connecting to database '{db}' on server '{srv}'...");
var connStr = "Server = LocalHost; Database = MyData;";
Console.WriteLine(t.Transform(connStr).Text);
// Note: Spaces around '=' handled automatically by default tokenization.
Connecting to database 'MyData' on server 'LocalHost'... using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // Anchors: "Server", "=", ";", "Database" // Variables: {srv}, {db} t.FromTo("Server={srv};Database={db};", "Connecting to database '{db}' on server '{srv}'..."); var connStr = "Server = LocalHost; Database = MyData;"; Console.WriteLine(t.Transform(connStr).Text); // Note: Spaces around '=' handled automatically by default tokenization.
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
// Anchors: "Server", "=", ";", "Database"
// Variables: {srv}, {db}
t.FromTo("Server={srv};Database={db};",
"Connecting to database '{db}' on server '{srv}'...");
auto connStr = "Server = LocalHost; Database = MyData;";
cout << t.Transform(connStr).Text() << endl;
// Note: Spaces around '=' handled automatically by default tokenization.
}
Connecting to database 'MyData' on server 'LocalHost'... #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); // Anchors: "Server", "=", ";", "Database" // Variables: {srv}, {db} t.FromTo("Server={srv};Database={db};", "Connecting to database '{db}' on server '{srv}'..."); auto connStr = "Server = LocalHost; Database = MyData;"; cout << t.Transform(connStr).Text() << endl; // Note: Spaces around '=' handled automatically by default tokenization. }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
'// Anchors: "Server", "=", ";", "Database"
'// Variables: {srv}, {db}
t.FromTo("Server={srv};Database={db};",
"Connecting to database '{db}' on server '{srv}'...")
Dim connStr = "Server = LocalHost; Database = MyData;"
Console.WriteLine(t.Transform(connStr).Text)
'// Note: Spaces around '=' handled automatically by default tokenization.
End Sub
End Module
Connecting to database 'MyData' on server 'LocalHost'... Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() '// Anchors: "Server", "=", ";", "Database" '// Variables: {srv}, {db} t.FromTo("Server={srv};Database={db};", "Connecting to database '{db}' on server '{srv}'...") Dim connStr = "Server = LocalHost; Database = MyData;" Console.WriteLine(t.Transform(connStr).Text) '// Note: Spaces around '=' handled automatically by default tokenization. End Sub End Module