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:
Gets or sets whether pattern matching for this rule treats whitespace as a significant token, overriding the transformer's default setting.
The WhitespaceSensitive property controls how a pattern rule interprets horizontal whitespace (spaces and tabs). By default, uCalc is whitespace-insensitive, offering flexibility. This property allows you to enforce strict whitespace matching for specific rules.
This per-rule setting overrides the global behavior defined on the parent Transformer's DefaultRuleSet.
| Setting | Behavior |
|---|---|
false (Default) | Insensitive. Whitespace is ignored. A space in a pattern can match any amount of horizontal whitespace in the source text, including none. The engine focuses on non-whitespace tokens. |
true | Sensitive. Whitespace becomes a significant token. A space in the pattern must match exactly one whitespace token in the source. This is crucial for formats where indentation or column alignment matters. |
This property provides a level of granular control not easily achieved with standard regular expressions.
vs. Regular Expressions: In regex, handling variable spacing requires littering patterns with \s+ or \s*. uCalc's default (false) behavior handles this automatically, making patterns cleaner and more readable. Enabling WhitespaceSensitive(true) is like making spaces in your pattern behave like \s+ in regex, but on a token level. This is a declarative switch rather than an imperative pattern change.
vs. Global Flags: Many regex engines apply case-sensitivity or multi-line options to the entire pattern. uCalc allows you to mix whitespace-sensitive and -insensitive rules within the same Transformer, letting them run concurrently. This is powerful for parsing hybrid documents that might have both structured (whitespace-sensitive) and unstructured (whitespace-insensitive) sections.
ID: 142
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
var Text = "This is a test.";
var p = t.FromTo("This {words:3}", "[{words}]");
Console.WriteLine($"Input: {Text}");
Console.WriteLine($"Pattern: {p.Pattern}");
Console.WriteLine("");
Console.WriteLine("3 captured tokens are in brackets");
Console.WriteLine("");
Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}");
Console.WriteLine(t.Transform(Text));
Console.WriteLine("");
t.DefaultRuleSet.WhitespaceSensitive = true;
Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}");
Console.WriteLine(t.Transform(Text));
Input: This is a test.
Pattern: This {words:3}
3 captured tokens are in brackets
WhitespaceSensitive = False
[is a test].
WhitespaceSensitive = True
[ is ]a test. using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); var Text = "This is a test."; var p = t.FromTo("This {words:3}", "[{words}]"); Console.WriteLine($"Input: {Text}"); Console.WriteLine($"Pattern: {p.Pattern}"); Console.WriteLine(""); Console.WriteLine("3 captured tokens are in brackets"); Console.WriteLine(""); Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}"); Console.WriteLine(t.Transform(Text)); Console.WriteLine(""); t.DefaultRuleSet.WhitespaceSensitive = true; Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}"); Console.WriteLine(t.Transform(Text));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
auto t = uc.NewTransformer();
auto Text = "This is a test.";
auto p = t.FromTo("This {words:3}", "[{words}]");
cout << "Input: " << Text << endl;
cout << "Pattern: " << p.Pattern() << endl;
cout << "" << endl;
cout << "3 captured tokens are in brackets" << endl;
cout << "" << endl;
cout << "WhitespaceSensitive = " << tf(t.DefaultRuleSet().WhitespaceSensitive()) << endl;
cout << t.Transform(Text) << endl;
cout << "" << endl;
t.DefaultRuleSet().WhitespaceSensitive(true);
cout << "WhitespaceSensitive = " << tf(t.DefaultRuleSet().WhitespaceSensitive()) << endl;
cout << t.Transform(Text) << endl;
}
Input: This is a test.
Pattern: This {words:3}
3 captured tokens are in brackets
WhitespaceSensitive = False
[is a test].
WhitespaceSensitive = True
[ is ]a test. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; auto t = uc.NewTransformer(); auto Text = "This is a test."; auto p = t.FromTo("This {words:3}", "[{words}]"); cout << "Input: " << Text << endl; cout << "Pattern: " << p.Pattern() << endl; cout << "" << endl; cout << "3 captured tokens are in brackets" << endl; cout << "" << endl; cout << "WhitespaceSensitive = " << tf(t.DefaultRuleSet().WhitespaceSensitive()) << endl; cout << t.Transform(Text) << endl; cout << "" << endl; t.DefaultRuleSet().WhitespaceSensitive(true); cout << "WhitespaceSensitive = " << tf(t.DefaultRuleSet().WhitespaceSensitive()) << endl; cout << t.Transform(Text) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
Dim Text = "This is a test."
Dim p = t.FromTo("This {words:3}", "[{words}]")
Console.WriteLine($"Input: {Text}")
Console.WriteLine($"Pattern: {p.Pattern}")
Console.WriteLine("")
Console.WriteLine("3 captured tokens are in brackets")
Console.WriteLine("")
Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}")
Console.WriteLine(t.Transform(Text))
Console.WriteLine("")
t.DefaultRuleSet.WhitespaceSensitive = true
Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}")
Console.WriteLine(t.Transform(Text))
End Sub
End Module
Input: This is a test.
Pattern: This {words:3}
3 captured tokens are in brackets
WhitespaceSensitive = False
[is a test].
WhitespaceSensitive = True
[ is ]a test. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() Dim Text = "This is a test." Dim p = t.FromTo("This {words:3}", "[{words}]") Console.WriteLine($"Input: {Text}") Console.WriteLine($"Pattern: {p.Pattern}") Console.WriteLine("") Console.WriteLine("3 captured tokens are in brackets") Console.WriteLine("") Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}") Console.WriteLine(t.Transform(Text)) Console.WriteLine("") t.DefaultRuleSet.WhitespaceSensitive = true Console.WriteLine($"WhitespaceSensitive = {t.DefaultRuleSet.WhitespaceSensitive}") Console.WriteLine(t.Transform(Text)) End Sub End Module