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.
Product:
Class:
A collection representing the results of a pattern matching operation, created by a Transformer.
The uCalc.Matches object is a read-only collection that holds the results of a pattern-matching operation performed by a uCalc.Transformer. It is not created directly; instead, it is returned by the Matches() method of a Transformer after calling Find(), Filter(), or Transform().
Matches Object ContainsThe collection represents all the substrings that successfully matched one of the transformer's defined patterns. For each match in the list, you can retrieve detailed information using its index:
To access the matches, you typically loop from 0 to Matches.Count() - 1.
csharp
var t = new uCalc.Transformer();
// ... define rules and input text ...
t.Find();
var m = t.Matches();
for (var i = 0; i <= m.Count() - 1; i++) {
Console.WriteLine($"Match {i}: {m.Str(i)}");
}
uCalc.Matches vs. Regex MatchCollectionIn environments like .NET, a regular expression search returns a MatchCollection. While functionally similar, uCalc's Matches object has distinct advantages rooted in its token-aware architecture.
Token Awareness vs. Character Awareness: A standard regex match is purely character-based and can easily fail on nested structures. uCalc's matches are token-aware. A match for {@Bracketed} will correctly capture (a + (b * c)), something that is extremely difficult for a simple regex. The resulting Matches object represents these structurally sound matches.
Rich Metadata: A regex match typically provides the captured string and its position. A uCalc match provides much richer context. The ability to retrieve the specific Rule that generated the match via Matches.Rule(i) is invaluable for debugging and for building applications with complex, layered logic where you need to know why something was matched.
ID: 114
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "Title
Bold statementOther textMy paragraph
";
// 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
// 0 10 20 30 40 50 60 70 80 90
// ^ ^ ^ ^ ^
// Carrets (^) represent starting and ending point of the matches
t.Pattern("<{tag}>{text}{tag}>");
t.Pattern("{text}");
t.Pattern("{text}
");
t.SkipOver("");
t.Find();
foreach(var match in t.Matches) {
Console.WriteLine(match.Text);
Console.WriteLine($"Start pos: {match.StartPosition}");
Console.WriteLine($"End pos: {match.EndPosition}");
Console.WriteLine($"Length: {match.Length}");
Console.WriteLine("");
}
<h3>Title</h3>
Start pos: 0
End pos: 14
Length: 14
<b>Bold statement</b>
Start pos: 14
End pos: 35
Length: 21
<b>Other text</b>
Start pos: 58
End pos: 75
Length: 17
<p>My paragraph</p>
Start pos: 75
End pos: 94
Length: 19 using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Text = "<h3>Title</h3><b>Bold statement</b><!--<h3>Title B</h3>--><b>Other text</b><p>My paragraph</p>"; // 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 // 0 10 20 30 40 50 60 70 80 90 // ^ ^ ^ ^ ^ // Carrets (^) represent starting and ending point of the matches t.Pattern("<{tag}>{text}</{tag}>"); t.Pattern("<b>{text}</b>"); t.Pattern("<h3>{text}</h3>"); t.SkipOver("<!--{text}-->"); t.Find(); foreach(var match in t.Matches) { Console.WriteLine(match.Text); Console.WriteLine($"Start pos: {match.StartPosition}"); Console.WriteLine($"End pos: {match.EndPosition}"); Console.WriteLine($"Length: {match.Length}"); Console.WriteLine(""); }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.Text("Title
Bold statementOther textMy paragraph
");
// 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
// 0 10 20 30 40 50 60 70 80 90
// ^ ^ ^ ^ ^
// Carrets (^) represent starting and ending point of the matches
t.Pattern("<{tag}>{text}{tag}>");
t.Pattern("{text}");
t.Pattern("{text}
");
t.SkipOver("");
t.Find();
for(auto match : t.Matches()) {
cout << match.Text() << endl;
cout << "Start pos: " << match.StartPosition() << endl;
cout << "End pos: " << match.EndPosition() << endl;
cout << "Length: " << match.Length() << endl;
cout << "" << endl;
}
}
<h3>Title</h3>
Start pos: 0
End pos: 14
Length: 14
<b>Bold statement</b>
Start pos: 14
End pos: 35
Length: 21
<b>Other text</b>
Start pos: 58
End pos: 75
Length: 17
<p>My paragraph</p>
Start pos: 75
End pos: 94
Length: 19 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.Text("<h3>Title</h3><b>Bold statement</b><!--<h3>Title B</h3>--><b>Other text</b><p>My paragraph</p>"); // 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 // 0 10 20 30 40 50 60 70 80 90 // ^ ^ ^ ^ ^ // Carrets (^) represent starting and ending point of the matches t.Pattern("<{tag}>{text}</{tag}>"); t.Pattern("<b>{text}</b>"); t.Pattern("<h3>{text}</h3>"); t.SkipOver("<!--{text}-->"); t.Find(); for(auto match : t.Matches()) { cout << match.Text() << endl; cout << "Start pos: " << match.StartPosition() << endl; cout << "End pos: " << match.EndPosition() << endl; cout << "Length: " << match.Length() << endl; cout << "" << endl; } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.Text = "Title
Bold statementOther textMy paragraph
"
'// 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
'// 0 10 20 30 40 50 60 70 80 90
'// ^ ^ ^ ^ ^
'// Carrets (^) represent starting and ending point of the matches
t.Pattern("<{tag}>{text}{tag}>")
t.Pattern("{text}")
t.Pattern("{text}
")
t.SkipOver("")
t.Find()
For Each match In t.Matches
Console.WriteLine(match.Text)
Console.WriteLine($"Start pos: {match.StartPosition}")
Console.WriteLine($"End pos: {match.EndPosition}")
Console.WriteLine($"Length: {match.Length}")
Console.WriteLine("")
Next
End Sub
End Module
<h3>Title</h3>
Start pos: 0
End pos: 14
Length: 14
<b>Bold statement</b>
Start pos: 14
End pos: 35
Length: 21
<b>Other text</b>
Start pos: 58
End pos: 75
Length: 17
<p>My paragraph</p>
Start pos: 75
End pos: 94
Length: 19 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.Text = "<h3>Title</h3><b>Bold statement</b><!--<h3>Title B</h3>--><b>Other text</b><p>My paragraph</p>" '// 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 '// 0 10 20 30 40 50 60 70 80 90 '// ^ ^ ^ ^ ^ '// Carrets (^) represent starting and ending point of the matches t.Pattern("<{tag}>{text}</{tag}>") t.Pattern("<b>{text}</b>") t.Pattern("<h3>{text}</h3>") t.SkipOver("<!--{text}-->") t.Find() For Each match In t.Matches Console.WriteLine(match.Text) Console.WriteLine($"Start pos: {match.StartPosition}") Console.WriteLine($"End pos: {match.EndPosition}") Console.WriteLine($"Length: {match.Length}") Console.WriteLine("") Next End Sub End Module