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:Â
Performs a pattern-matching operation and returns a new string consisting only of the transformed matches.
Current object
[Revisit]The Filter() method performs a pattern-matching operation similar to Find() but produces a new string composed exclusively of the results. Unlike Transform(), which modifies the source text in-place, Filter() extracts the matches and concatenates their transformed output, with each result separated by a newline.
This makes it the ideal tool for data extraction, summarization, or creating a new document from selected parts of an original.
Find() vs. Filter() vs. Transform()Choosing the correct method is key to efficient text processing. This table clarifies their distinct purposes:
| Method | Purpose | Result | Use Case |
|---|---|---|---|
Find() | Locate | Populates the Matches collection with the locations of patterns. Does not produce an output string. | When you only need to know if and where patterns exist. |
Filter() | Extract & Transform | Creates a new string consisting only of the transformed results of each match, separated by newlines. | Extracting all log errors, URLs, or specific data points from a document into a clean list. |
Transform() | Modify In-Place | Modifies the original text, replacing matches according to rules but preserving all other content. | Performing a search-and-replace operation on a document. |
The output of Filter() is built from the replacement part of each matching rule defined with FromTo(). If a rule was defined with Pattern(), which has no explicit replacement, the matched text itself ({@Self}) is used.
In a standard Regex workflow, achieving the same result as Filter() is a multi-step, manual process:
StringBuilder or a List<string> in your host language (C#/C++).Filter() encapsulates this entire workflow into a single, highly optimized method call. You define your extraction and transformation logic declaratively, and the engine handles the iteration, transformation, and string concatenation internally, leading to code that is cleaner, faster, and less error-prone.
ID: 130
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "(5+4) this and that etc";
var a = t.Pattern("<{tg}>");
var b = t.Pattern("This {body} That");
var c = t.Pattern("etc");
var d = t.Pattern("({expr})");
t.Filter();
Console.WriteLine("--- Matches ---");
Console.WriteLine(t.Matches.Text);
Console.WriteLine("--- Pattern names ---");
Console.WriteLine(a.Name);
Console.WriteLine(b.Name);
Console.WriteLine(c.Name);
Console.WriteLine(d.Name);
Console.WriteLine("--- Pattern defs ---");
Console.WriteLine(a.Pattern);
Console.WriteLine(b.Pattern);
Console.WriteLine(c.Pattern);
Console.WriteLine(d.Pattern);
--- Matches ---
<b>
(5+4)
</b>
this and that
etc
--- Pattern names ---
<
this
etc
(
--- Pattern defs ---
<{tg}>
This {body} That
etc
({expr}) using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Text = "<b>(5+4)</b> this and that etc"; var a = t.Pattern("<{tg}>"); var b = t.Pattern("This {body} That"); var c = t.Pattern("etc"); var d = t.Pattern("({expr})"); t.Filter(); Console.WriteLine("--- Matches ---"); Console.WriteLine(t.Matches.Text); Console.WriteLine("--- Pattern names ---"); Console.WriteLine(a.Name); Console.WriteLine(b.Name); Console.WriteLine(c.Name); Console.WriteLine(d.Name); Console.WriteLine("--- Pattern defs ---"); Console.WriteLine(a.Pattern); Console.WriteLine(b.Pattern); Console.WriteLine(c.Pattern); Console.WriteLine(d.Pattern);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.Text("(5+4) this and that etc");
auto a = t.Pattern("<{tg}>");
auto b = t.Pattern("This {body} That");
auto c = t.Pattern("etc");
auto d = t.Pattern("({expr})");
t.Filter();
cout << "--- Matches ---" << endl;
cout << t.Matches().Text() << endl;
cout << "--- Pattern names ---" << endl;
cout << a.Name() << endl;
cout << b.Name() << endl;
cout << c.Name() << endl;
cout << d.Name() << endl;
cout << "--- Pattern defs ---" << endl;
cout << a.Pattern() << endl;
cout << b.Pattern() << endl;
cout << c.Pattern() << endl;
cout << d.Pattern() << endl;
}
--- Matches ---
<b>
(5+4)
</b>
this and that
etc
--- Pattern names ---
<
this
etc
(
--- Pattern defs ---
<{tg}>
This {body} That
etc
({expr}) #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.Text("<b>(5+4)</b> this and that etc"); auto a = t.Pattern("<{tg}>"); auto b = t.Pattern("This {body} That"); auto c = t.Pattern("etc"); auto d = t.Pattern("({expr})"); t.Filter(); cout << "--- Matches ---" << endl; cout << t.Matches().Text() << endl; cout << "--- Pattern names ---" << endl; cout << a.Name() << endl; cout << b.Name() << endl; cout << c.Name() << endl; cout << d.Name() << endl; cout << "--- Pattern defs ---" << endl; cout << a.Pattern() << endl; cout << b.Pattern() << endl; cout << c.Pattern() << endl; cout << d.Pattern() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.Text = "(5+4) this and that etc"
Dim a = t.Pattern("<{tg}>")
Dim b = t.Pattern("This {body} That")
Dim c = t.Pattern("etc")
Dim d = t.Pattern("({expr})")
t.Filter()
Console.WriteLine("--- Matches ---")
Console.WriteLine(t.Matches.Text)
Console.WriteLine("--- Pattern names ---")
Console.WriteLine(a.Name)
Console.WriteLine(b.Name)
Console.WriteLine(c.Name)
Console.WriteLine(d.Name)
Console.WriteLine("--- Pattern defs ---")
Console.WriteLine(a.Pattern)
Console.WriteLine(b.Pattern)
Console.WriteLine(c.Pattern)
Console.WriteLine(d.Pattern)
End Sub
End Module
--- Matches ---
<b>
(5+4)
</b>
this and that
etc
--- Pattern names ---
<
this
etc
(
--- Pattern defs ---
<{tg}>
This {body} That
etc
({expr}) Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.Text = "<b>(5+4)</b> this and that etc" Dim a = t.Pattern("<{tg}>") Dim b = t.Pattern("This {body} That") Dim c = t.Pattern("etc") Dim d = t.Pattern("({expr})") t.Filter() Console.WriteLine("--- Matches ---") Console.WriteLine(t.Matches.Text) Console.WriteLine("--- Pattern names ---") Console.WriteLine(a.Name) Console.WriteLine(b.Name) Console.WriteLine(c.Name) Console.WriteLine(d.Name) Console.WriteLine("--- Pattern defs ---") Console.WriteLine(a.Pattern) Console.WriteLine(b.Pattern) Console.WriteLine(c.Pattern) Console.WriteLine(d.Pattern) End Sub End Module