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.
Explains how to link multiple uCalc.String operations together in a single, readable statement to create powerful text-processing pipelines.
[revisit]
One of the most powerful features of the uCalc.String class is its fluent interface. This means that most methods return the uCalc.String object itself, allowing you to "chain" multiple operations together into a single, highly readable statement. This turns complex, multi-step text manipulations into concise, elegant pipelines.
The core concept behind chaining is the "live view." Methods that extract a portion of a string—like After(), Before(), and Between()—do not create a disconnected copy of the text. Instead, they return a new uCalc.String object that acts as a live, modifiable window or "view" into the original, parent string.
Think of it like focusing a lens:
uCalc.String).After("start") to create a view focused only on the text after your starting point..Between("(", ")") onto that view, narrowing your focus even further to just the content inside the parentheses..Replace("old", "new") to that focused view.Because the view is live, the replacement you make is reflected directly in the original, parent string. This allows for incredibly powerful and efficient in-place editing.
In traditional string manipulation, achieving the same result requires a verbose, multi-step process that creates temporary, disconnected string objects at each stage.
Typical C# Approach (Manual & Inefficient):
string text = "config user='admin' level=9";int userPos = text.IndexOf("user=") + 5; // Find startstring temp1 = text.Substring(userPos); // Create first temp stringint startQuote = temp1.IndexOf("'") + 1;int endQuote = temp1.IndexOf("'", startQuote);string username = temp1.Substring(startQuote, endQuote - startQuote); // Create second temp stringstring modifiedUsername = username.ToUpper(); // Create third temp stringstring final = text.Replace(username, modifiedUsername); // Create final stringThis code is hard to read, inefficient due to multiple string allocations, and prone to off-by-one errors.
The uCalc Fluent Approach (Clean & Efficient):csharpThis single line of code achieves the same result by creating a pipeline of live views. It is more readable, less error-prone, and performs better by avoiding the creation of intermediate string copies.
using (var s = new uCalc.String("config user='admin' level=9")) {
s.After("user=").Between("'", "'").ToUpper();
}
ID: 1260
using uCalcSoftware;
var uc = new uCalc();
using (var s = new uCalc.String("A and C")) {
// Each Replace() call returns the modified string object, allowing the next call.
s.Replace("A", "B").Replace("C", "D");
Console.Write("Result: ");
Console.WriteLine(s);
};
Result: B and D using uCalcSoftware; var uc = new uCalc(); using (var s = new uCalc.String("A and C")) { // Each Replace() call returns the modified string object, allowing the next call. s.Replace("A", "B").Replace("C", "D"); Console.Write("Result: "); Console.WriteLine(s); };
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
{
uCalc::String s("A and C");
s.Owned(); // Causes s to be released when it goes out of scope
// Each Replace() call returns the modified string object, allowing the next call.
s.Replace("A", "B").Replace("C", "D");
cout << "Result: ";
cout << s << endl;
};
}
Result: B and D #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; { uCalc::String s("A and C"); s.Owned(); // Causes s to be released when it goes out of scope // Each Replace() call returns the modified string object, allowing the next call. s.Replace("A", "B").Replace("C", "D"); cout << "Result: "; cout << s << endl; }; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Using s As New uCalc.String("A and C")
'// Each Replace() call returns the modified string object, allowing the next call.
s.Replace("A", "B").Replace("C", "D")
Console.Write("Result: ")
Console.WriteLine(s)
End Using
End Sub
End Module
Result: B and D Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Using s As New uCalc.String("A and C") '// Each Replace() call returns the modified string object, allowing the next call. s.Replace("A", "B").Replace("C", "D") Console.Write("Result: ") Console.WriteLine(s) End Using End Sub End Module