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:
An overview of the uCalc.String class, a mutable, token-aware string object designed for high-performance, chainable text manipulation.
The uCalc.String object is a powerful, mutable string class designed for high-performance text manipulation. It goes far beyond a standard string or StringBuilder, acting as a hybrid of three components in one:
Its core design philosophy is to provide a rich, fluent interface for single-string operations. For managing complex sets of reusable rules or multi-pass transformations, the more powerful uCalc.Transformer is the preferred tool.
Unlike native string types in C# and other languages, which are immutable, uCalc.String is designed to be modified in-place. This makes it highly efficient for building or manipulating strings in a loop, similar to a StringBuilder but with far more functionality.
By default, all operations (like SubString, After, and Before) are token-based, not character-based. The string is first broken down into tokens (words, numbers, symbols), and operations are performed on this stream. This provides structural awareness, safely handling nested brackets, quotes, or user-defined constructs like comments.
Methods that extract a portion of a string (e.g., SubString, After, Between) do not create a disconnected copy. Instead, they return a new uCalc.String object that is a live, modifiable view into the parent.
This architecture enables powerful, non-destructive editing pipelines.
After a Find() operation or by calling methods like ListOfTokens(), the uCalc.String object begins to act like a collection of results. Subsequent chained operations are then applied to each item in that collection, enabling powerful batch processing with methods like Map().
uCalc.String vs. uCalc.TransformerIt's important to choose the right tool for the job. While both share the same underlying tokenization engine, they offer different interfaces for different tasks:
uCalc.String: Best for fluent, single-string "one-liner" transformations. Think of it as a scripting tool for quick modifications and data extraction on a single piece of text.
Transformer: Best for building a robust, rule-based system. It excels at managing a complex set of reusable rules or performing multi-pass transformations. Think of it as a compiler for text.
Below is a list of members available on the uCalc.String class, grouped by functionality.
These methods return a new uCalc.String object that is a live view into a portion of the original.
| Member | Description |
|---|---|
| After | Creates a live, modifiable view of the substring that follows a specified pattern match. |
| Before | Creates a live, modifiable view of the substring that precedes a specified pattern match. |
| Between | Creates a live, modifiable view of the substring located between two specified patterns. |
| BetweenInclusive | Creates a live, modifiable view of the substring that includes the text between two specified patterns and the patterns themselves. |
| StartingFrom | Creates a live, modifiable view of the substring that begins with and includes a specified pattern match. |
| SubString | Extracts a substring of a specified length starting at a given token position. |
| UpTo | Returns a substring with all text up to and including the matched pattern. |
These methods modify the string's content in-place or change its representation.
| Member | Description |
|---|---|
| Find | Searches for occurrences of a pattern, populating the internal match list. |
| Remove | Removes all occurrences of a specified pattern from the string. |
| Replace | Replaces all occurrences of a specified pattern with a new string. |
| ToLower | Converts the string or a specified pattern match to lowercase. |
| ToUpper | Converts the string or a specified pattern match to uppercase. |
| Map | Applies a transformation expression to each item in the string's internal list. |
| Transform | Applies the rules of a specified Transformer object to this string. |
These members return information about the string's content or state.
| Member | Description |
|---|---|
| Text | Gets or sets the full text content of the string object. |
| Count | Gets the number of items in the string's current view (e.g., tokens, matches, lines). |
| Parent | Retrieves the parent uCalc.String object from which this view was created. |
| Root | Retrieves the top-level uCalc.String object in a chain of views. |
| uCalc | Retrieves the parent uCalc instance that provides the execution context. |
| Description | Gets or sets a user-defined description for the object. |
ID: 1273
using uCalcSoftware;
var uc = new uCalc();
using (var s = new uCalc.String("User: admin; Role: user; Department: Sales;")) {
// Extract the text between 'Department: ' and the trailing semicolon
var department = s.Between("Department: ", ";");
Console.WriteLine($"Department is '{department}'");
}
Department is ' Sales' using uCalcSoftware; var uc = new uCalc(); using (var s = new uCalc.String("User: admin; Role: user; Department: Sales;")) { // Extract the text between 'Department: ' and the trailing semicolon var department = s.Between("Department: ", ";"); Console.WriteLine($"Department is '{department}'"); }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
{
uCalc::String s("User: admin; Role: user; Department: Sales;");
s.Owned(); // Causes s to be released when it goes out of scope
// Extract the text between 'Department: ' and the trailing semicolon
auto department = s.Between("Department: ", ";");
cout << "Department is '" << department << "'" << endl;
}
}
Department is ' Sales' #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; { uCalc::String s("User: admin; Role: user; Department: Sales;"); s.Owned(); // Causes s to be released when it goes out of scope // Extract the text between 'Department: ' and the trailing semicolon auto department = s.Between("Department: ", ";"); cout << "Department is '" << department << "'" << endl; } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Using s As New uCalc.String("User: admin; Role: user; Department: Sales;")
'// Extract the text between 'Department: ' and the trailing semicolon
Dim department = s.Between("Department: ", ";")
Console.WriteLine($"Department is '{department}'")
End Using
End Sub
End Module
Department is ' Sales' Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Using s As New uCalc.String("User: admin; Role: user; Department: Sales;") '// Extract the text between 'Department: ' and the trailing semicolon Dim department = s.Between("Department: ", ";") Console.WriteLine($"Department is '{department}'") End Using End Sub End Module
ID: 1270
using uCalcSoftware;
var uc = new uCalc();
using (var url = new uCalc.String("http://example.com")) {
Console.WriteLine($"Original URL: {url}");
// Get a view of the scheme part
var schemeView = url.Before("://");
// Modify the view
schemeView.Replace("http", "https");
// The original string is updated
Console.WriteLine($"Modified URL: {url}");
}
Original URL: http://example.com
Modified URL: https://example.com using uCalcSoftware; var uc = new uCalc(); using (var url = new uCalc.String("http://example.com")) { Console.WriteLine($"Original URL: {url}"); // Get a view of the scheme part var schemeView = url.Before("://"); // Modify the view schemeView.Replace("http", "https"); // The original string is updated Console.WriteLine($"Modified URL: {url}"); }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
{
uCalc::String url("http://example.com");
url.Owned(); // Causes url to be released when it goes out of scope
cout << "Original URL: " << url << endl;
// Get a view of the scheme part
auto schemeView = url.Before("://");
// Modify the view
schemeView.Replace("http", "https");
// The original string is updated
cout << "Modified URL: " << url << endl;
}
}
Original URL: http://example.com
Modified URL: https://example.com #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; { uCalc::String url("http://example.com"); url.Owned(); // Causes url to be released when it goes out of scope cout << "Original URL: " << url << endl; // Get a view of the scheme part auto schemeView = url.Before("://"); // Modify the view schemeView.Replace("http", "https"); // The original string is updated cout << "Modified URL: " << url << endl; } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Using url As New uCalc.String("http://example.com")
Console.WriteLine($"Original URL: {url}")
'// Get a view of the scheme part
Dim schemeView = url.Before("://")
'// Modify the view
schemeView.Replace("http", "https")
'// The original string is updated
Console.WriteLine($"Modified URL: {url}")
End Using
End Sub
End Module
Original URL: http://example.com
Modified URL: https://example.com Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Using url As New uCalc.String("http://example.com") Console.WriteLine($"Original URL: {url}") '// Get a view of the scheme part Dim schemeView = url.Before("://") '// Modify the view schemeView.Replace("http", "https") '// The original string is updated Console.WriteLine($"Modified URL: {url}") End Using End Sub End Module