uCalc SDK Interactive Examples
(Default Matching) Identifying any brackets and normalizing them to a standard parentheses.
ID: 923
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@Bracket}", "(");
t.FromTo("{@CloseBracket}", ")");
Console.WriteLine(t.Transform("{a, b, c} f(x, y) [1, 2, 3];"));
(a, b, c) f(x, y) (1, 2, 3); using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("{@Bracket}", "("); t.FromTo("{@CloseBracket}", ")"); Console.WriteLine(t.Transform("{a, b, c} f(x, y) [1, 2, 3];"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("{@Bracket}", "(");
t.FromTo("{@CloseBracket}", ")");
cout << t.Transform("{a, b, c} f(x, y) [1, 2, 3];") << endl;
}
(a, b, c) f(x, y) (1, 2, 3); #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("{@Bracket}", "("); t.FromTo("{@CloseBracket}", ")"); cout << t.Transform("{a, b, c} f(x, y) [1, 2, 3];") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("{@Bracket}", "(")
t.FromTo("{@CloseBracket}", ")")
Console.WriteLine(t.Transform("{a, b, c} f(x, y) [1, 2, 3];"))
End Sub
End Module
(a, b, c) f(x, y) (1, 2, 3); Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("{@Bracket}", "(") t.FromTo("{@CloseBracket}", ")") Console.WriteLine(t.Transform("{a, b, c} f(x, y) [1, 2, 3];")) End Sub End Module
(Mixed Delimiter Check) Verifying that `{@sq}` captures only single quotes (ignoring double quotes).
ID: 902
See: {@sq}, Introduction
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@sq}", "$");
// Only the single quote should be replaced
Console.WriteLine(t.Transform("""
"Hello" and 'World'
"""));
"Hello" and $World$ using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("{@sq}", "$"); // Only the single quote should be replaced Console.WriteLine(t.Transform(""" "Hello" and 'World' """));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("{@sq}", "$");
// Only the single quote should be replaced
cout << t.Transform(R"("Hello" and 'World')") << endl;
}
"Hello" and $World$ #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("{@sq}", "$"); // Only the single quote should be replaced cout << t.Transform(R"("Hello" and 'World')") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("{@sq}", "$")
'// Only the single quote should be replaced
Console.WriteLine(t.Transform("""Hello"" and 'World'"))
End Sub
End Module
"Hello" and $World$ Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("{@sq}", "$") '// Only the single quote should be replaced Console.WriteLine(t.Transform("""Hello"" and 'World'")) End Sub End Module
(Non-delimiter characters) Verifying that `{@QuoteChar}` does not match characters that are not defined as string delimiters in the engine.
ID: 908
See: {@QuoteChar}
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@QuoteChar}", "MATCH");
// Backticks (`) are usually not delimiters by default
Console.WriteLine(t.Transform("`Backtick`"));
`Backtick` using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("{@QuoteChar}", "MATCH"); // Backticks (`) are usually not delimiters by default Console.WriteLine(t.Transform("`Backtick`"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("{@QuoteChar}", "MATCH");
// Backticks (`) are usually not delimiters by default
cout << t.Transform("`Backtick`") << endl;
}
`Backtick` #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("{@QuoteChar}", "MATCH"); // Backticks (`) are usually not delimiters by default cout << t.Transform("`Backtick`") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("{@QuoteChar}", "MATCH")
'// Backticks (`) are usually not delimiters by default
Console.WriteLine(t.Transform("`Backtick`"))
End Sub
End Module
`Backtick` Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("{@QuoteChar}", "MATCH") '// Backticks (`) are usually not delimiters by default Console.WriteLine(t.Transform("`Backtick`")) End Sub End Module
(Real World: Currency Formatter) Finding raw numbers in a text stream and converting them to a formatted currency string.
ID: 251
See: {@Number}, Introduction
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("Price: {@Number:amt}", "Price: ${amt}");
string input = "Item A Price: 19.99, Item B Price: 5";
Console.WriteLine(t.Transform(input));
Item A Price: $19.99, Item B Price: $5 using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("Price: {@Number:amt}", "Price: ${amt}"); string input = "Item A Price: 19.99, Item B Price: 5"; Console.WriteLine(t.Transform(input));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("Price: {@Number:amt}", "Price: ${amt}");
string input = "Item A Price: 19.99, Item B Price: 5";
cout << t.Transform(input) << endl;
}
Item A Price: $19.99, Item B Price: $5 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("Price: {@Number:amt}", "Price: ${amt}"); string input = "Item A Price: 19.99, Item B Price: 5"; cout << t.Transform(input) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("Price: {@Number:amt}", "Price: ${amt}")
Dim input As String = "Item A Price: 19.99, Item B Price: 5"
Console.WriteLine(t.Transform(input))
End Sub
End Module
Item A Price: $19.99, Item B Price: $5 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("Price: {@Number:amt}", "Price: ${amt}") Dim input As String = "Item A Price: 19.99, Item B Price: 5" Console.WriteLine(t.Transform(input)) End Sub End Module
(Real World: Escaping Helper) Finding double quotes to manually insert an escape backslash before them.
ID: 921
See: {@dq}, Introduction
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@dq}", """
\"
""");
string input = """
He said "Hello"
""";
Console.WriteLine(t.Transform(input));
He said \"Hello\" using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("{@dq}", """ \" """); string input = """ He said "Hello" """; Console.WriteLine(t.Transform(input));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("{@dq}", R"(\")");
string input = R"(He said "Hello")";
cout << t.Transform(input) << endl;
}
He said \"Hello\" #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("{@dq}", R"(\")"); string input = R"(He said "Hello")"; cout << t.Transform(input) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("{@dq}", "\""")
Dim input As String = "He said ""Hello"""
Console.WriteLine(t.Transform(input))
End Sub
End Module
He said \"Hello\" Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("{@dq}", "\""") Dim input As String = "He said ""Hello""" Console.WriteLine(t.Transform(input)) End Sub End Module
(Real World: Quote Normalizer) Converting all string literals to use double quotes, regardless of whether they were originally single or double quoted.
ID: 907
See: {@QuoteChar}
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
// Convert any quote character found to a double quote
t.FromTo("{@QuoteChar}", """
"
""");
string input = """
msg = 'Hello'; val = "World";
""";
Console.WriteLine(t.Transform(input));
msg = "Hello"; val = "World"; using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); // Convert any quote character found to a double quote t.FromTo("{@QuoteChar}", """ " """); string input = """ msg = 'Hello'; val = "World"; """; Console.WriteLine(t.Transform(input));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
// Convert any quote character found to a double quote
t.FromTo("{@QuoteChar}", R"(")");
string input = R"(msg = 'Hello'; val = "World";)";
cout << t.Transform(input) << endl;
}
msg = "Hello"; val = "World"; #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; // Convert any quote character found to a double quote t.FromTo("{@QuoteChar}", R"(")"); string input = R"(msg = 'Hello'; val = "World";)"; cout << t.Transform(input) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
'// Convert any quote character found to a double quote
t.FromTo("{@QuoteChar}", """")
Dim input As String = "msg = 'Hello'; val = ""World"";"
Console.WriteLine(t.Transform(input))
End Sub
End Module
msg = "Hello"; val = "World"; Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() '// Convert any quote character found to a double quote t.FromTo("{@QuoteChar}", """") Dim input As String = "msg = 'Hello'; val = ""World"";" Console.WriteLine(t.Transform(input)) End Sub End Module
(Real World: Sensitive Data Redaction) Masking the content of all string literals in a log or script, while preserving the non-string code structure.
ID: 896
See: {@String}
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
// Replace every string literal with a placeholder
t.FromTo("{@String}", """
"[REDACTED]"
""");
string log = """
UserLogin(id: 101, pass: 'secret123', name: "Admin")
""";
Console.WriteLine(t.Transform(log));
UserLogin(id: 101, pass: "[REDACTED]", name: "[REDACTED]") using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); // Replace every string literal with a placeholder t.FromTo("{@String}", """ "[REDACTED]" """); string log = """ UserLogin(id: 101, pass: 'secret123', name: "Admin") """; Console.WriteLine(t.Transform(log));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
// Replace every string literal with a placeholder
t.FromTo("{@String}", R"("[REDACTED]")");
string log = R"(UserLogin(id: 101, pass: 'secret123', name: "Admin"))";
cout << t.Transform(log) << endl;
}
UserLogin(id: 101, pass: "[REDACTED]", name: "[REDACTED]") #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; // Replace every string literal with a placeholder t.FromTo("{@String}", R"("[REDACTED]")"); string log = R"(UserLogin(id: 101, pass: 'secret123', name: "Admin"))"; cout << t.Transform(log) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
'// Replace every string literal with a placeholder
t.FromTo("{@String}", """[REDACTED]""")
Dim log As String = "UserLogin(id: 101, pass: 'secret123', name: ""Admin"")"
Console.WriteLine(t.Transform(log))
End Sub
End Module
UserLogin(id: 101, pass: "[REDACTED]", name: "[REDACTED]") Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() '// Replace every string literal with a placeholder t.FromTo("{@String}", """[REDACTED]""") Dim log As String = "UserLogin(id: 101, pass: 'secret123', name: ""Admin"")" Console.WriteLine(t.Transform(log)) End Sub End Module
(Real World: SQL-style Escaping) Doubling up single quotes to escape them for a SQL query.
ID: 901
See: {@sq}
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@sq}", "''");
string input = "It's a trap";
Console.WriteLine(t.Transform(input));
It''s a trap using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("{@sq}", "''"); string input = "It's a trap"; Console.WriteLine(t.Transform(input));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("{@sq}", "''");
string input = "It's a trap";
cout << t.Transform(input) << endl;
}
It''s a trap #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("{@sq}", "''"); string input = "It's a trap"; cout << t.Transform(input) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("{@sq}", "''")
Dim input As String = "It's a trap"
Console.WriteLine(t.Transform(input))
End Sub
End Module
It''s a trap Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("{@sq}", "''") Dim input As String = "It's a trap" Console.WriteLine(t.Transform(input)) End Sub End Module
(Real World: Structure Identification) Labeling the start of complex data structures in a mixed text stream.
ID: 930
See: {@Bracket}
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("{@Bracket}", "[START_SCOPE]");
string input = "func { data [ 1, 2 ] }";
Console.WriteLine(t.Transform(input));
func [START_SCOPE] data [START_SCOPE] 1, 2 ] } using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("{@Bracket}", "[START_SCOPE]"); string input = "func { data [ 1, 2 ] }"; Console.WriteLine(t.Transform(input));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("{@Bracket}", "[START_SCOPE]");
string input = "func { data [ 1, 2 ] }";
cout << t.Transform(input) << endl;
}
func [START_SCOPE] data [START_SCOPE] 1, 2 ] } #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("{@Bracket}", "[START_SCOPE]"); string input = "func { data [ 1, 2 ] }"; cout << t.Transform(input) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("{@Bracket}", "[START_SCOPE]")
Dim input As String = "func { data [ 1, 2 ] }"
Console.WriteLine(t.Transform(input))
End Sub
End Module
func [START_SCOPE] data [START_SCOPE] 1, 2 ] } Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("{@Bracket}", "[START_SCOPE]") Dim input As String = "func { data [ 1, 2 ] }" Console.WriteLine(t.Transform(input)) End Sub End Module
(Real World: Value Masking)
ID: 915
See: {@Literal}, Introduction
using uCalcSoftware;
var uc = new uCalc();
// Creating a "Clean View" of a log or configuration file by replacing all
// actual data values with a placeholder, leaving only the structural identifiers.
var t = new uCalc.Transformer();
// Replace every literal with a generic placeholder
t.FromTo("{@Literal}", "?");
string input = """
setting_a = 500; setting_b = "active";
""";
Console.WriteLine(t.Transform(input));
setting_a = ?; setting_b = ?; using uCalcSoftware; var uc = new uCalc(); // Creating a "Clean View" of a log or configuration file by replacing all // actual data values with a placeholder, leaving only the structural identifiers. var t = new uCalc.Transformer(); // Replace every literal with a generic placeholder t.FromTo("{@Literal}", "?"); string input = """ setting_a = 500; setting_b = "active"; """; Console.WriteLine(t.Transform(input));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Creating a "Clean View" of a log or configuration file by replacing all
// actual data values with a placeholder, leaving only the structural identifiers.
uCalc::Transformer t;
// Replace every literal with a generic placeholder
t.FromTo("{@Literal}", "?");
string input = R"(setting_a = 500; setting_b = "active";)";
cout << t.Transform(input) << endl;
}
setting_a = ?; setting_b = ?; #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Creating a "Clean View" of a log or configuration file by replacing all // actual data values with a placeholder, leaving only the structural identifiers. uCalc::Transformer t; // Replace every literal with a generic placeholder t.FromTo("{@Literal}", "?"); string input = R"(setting_a = 500; setting_b = "active";)"; cout << t.Transform(input) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Creating a "Clean View" of a log or configuration file by replacing all
'// actual data values with a placeholder, leaving only the structural identifiers.
Dim t As New uCalc.Transformer()
'// Replace every literal with a generic placeholder
t.FromTo("{@Literal}", "?")
Dim input As String = "setting_a = 500; setting_b = ""active"";"
Console.WriteLine(t.Transform(input))
End Sub
End Module
setting_a = ?; setting_b = ?; Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Creating a "Clean View" of a log or configuration file by replacing all '// actual data values with a placeholder, leaving only the structural identifiers. Dim t As New uCalc.Transformer() '// Replace every literal with a generic placeholder t.FromTo("{@Literal}", "?") Dim input As String = "setting_a = 500; setting_b = ""active"";" Console.WriteLine(t.Transform(input)) End Sub End Module
{@All}
ID: 203
See: {@All}
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("{@All}", "<<{@Self}>>");
Console.WriteLine(t.Transform("This is a test"));
<<This is a test>> using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("{@All}", "<<{@Self}>>"); Console.WriteLine(t.Transform("This is a test"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("{@All}", "<<{@Self}>>");
cout << t.Transform("This is a test") << endl;
}
<<This is a test>> #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("{@All}", "<<{@Self}>>"); cout << t.Transform("This is a test") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("{@All}", "<<{@Self}>>")
Console.WriteLine(t.Transform("This is a test"))
End Sub
End Module
<<This is a test>> Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("{@All}", "<<{@Self}>>") Console.WriteLine(t.Transform("This is a test")) End Sub End Module
{@Alphanumeric}
ID: 177
See: {@Alphanumeric}, Introduction
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("({@Alphanumeric:txt})", "");
Console.WriteLine(t.Transform("Testing 123 (456) (abc) ('text') (xyz111)"));
Testing 123 (456) <Alpha str=abc> ('text') <Alpha str=xyz111> using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("({@Alphanumeric:txt})", "<Alpha str={txt}>"); Console.WriteLine(t.Transform("Testing 123 (456) (abc) ('text') (xyz111)"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("({@Alphanumeric:txt})", "");
cout << t.Transform("Testing 123 (456) (abc) ('text') (xyz111)") << endl;
}
Testing 123 (456) <Alpha str=abc> ('text') <Alpha str=xyz111> #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("({@Alphanumeric:txt})", "<Alpha str={txt}>"); cout << t.Transform("Testing 123 (456) (abc) ('text') (xyz111)") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("({@Alphanumeric:txt})", "")
Console.WriteLine(t.Transform("Testing 123 (456) (abc) ('text') (xyz111)"))
End Sub
End Module
Testing 123 (456) <Alpha str=abc> ('text') <Alpha str=xyz111> Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("({@Alphanumeric:txt})", "<Alpha str={txt}>") Console.WriteLine(t.Transform("Testing 123 (456) (abc) ('text') (xyz111)")) End Sub End Module
{@Comment}
ID: 205
See: {@Comment}
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("a {@Comment: Ignore this} b c", "x{@Comment: ignore} y z");
Console.WriteLine(t.Transform("a b. a b c. abc."));
a b. x y z. abc. using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("a {@Comment: Ignore this} b c", "x{@Comment: ignore} y z"); Console.WriteLine(t.Transform("a b. a b c. abc."));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("a {@Comment: Ignore this} b c", "x{@Comment: ignore} y z");
cout << t.Transform("a b. a b c. abc.") << endl;
}
a b. x y z. abc. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("a {@Comment: Ignore this} b c", "x{@Comment: ignore} y z"); cout << t.Transform("a b. a b c. abc.") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("a {@Comment: Ignore this} b c", "x{@Comment: ignore} y z")
Console.WriteLine(t.Transform("a b. a b c. abc."))
End Sub
End Module
a b. x y z. abc. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("a {@Comment: Ignore this} b c", "x{@Comment: ignore} y z") Console.WriteLine(t.Transform("a b. a b c. abc.")) End Sub End Module
{@Define}
ID: 206
See: {@Define}
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Pattern("{@Define: Var: xyz = 123}");
t.FromTo("abc", "{@Eval: xyz * 10}");
Console.WriteLine(t.Transform("The value is: abc"));
The value is: 1230 using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Pattern("{@Define: Var: xyz = 123}"); t.FromTo("abc", "{@Eval: xyz * 10}"); Console.WriteLine(t.Transform("The value is: abc"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.Pattern("{@Define: Var: xyz = 123}");
t.FromTo("abc", "{@Eval: xyz * 10}");
cout << t.Transform("The value is: abc") << endl;
}
The value is: 1230 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.Pattern("{@Define: Var: xyz = 123}"); t.FromTo("abc", "{@Eval: xyz * 10}"); cout << t.Transform("The value is: abc") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.Pattern("{@Define: Var: xyz = 123}")
t.FromTo("abc", "{@Eval: xyz * 10}")
Console.WriteLine(t.Transform("The value is: abc"))
End Sub
End Module
The value is: 1230 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.Pattern("{@Define: Var: xyz = 123}") t.FromTo("abc", "{@Eval: xyz * 10}") Console.WriteLine(t.Transform("The value is: abc")) End Sub End Module
{@Doc}
ID: 207
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("a test", "'{@Self}' is part of: '{@Doc}'");
// Note: .Str(0) here is a shortcut for .Matches().Str(0)
Console.WriteLine(t.Transform("This sentence is just a test").Str(0));
'a test' is part of: 'This sentence is just a test' using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("a test", "'{@Self}' is part of: '{@Doc}'"); // Note: .Str(0) here is a shortcut for .Matches().Str(0) Console.WriteLine(t.Transform("This sentence is just a test").Str(0));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("a test", "'{@Self}' is part of: '{@Doc}'");
// Note: .Str(0) here is a shortcut for .Matches().Str(0)
cout << t.Transform("This sentence is just a test").Str(0) << endl;
}
'a test' is part of: 'This sentence is just a test' #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("a test", "'{@Self}' is part of: '{@Doc}'"); // Note: .Str(0) here is a shortcut for .Matches().Str(0) cout << t.Transform("This sentence is just a test").Str(0) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("a test", "'{@Self}' is part of: '{@Doc}'")
'// Note: .Str(0) here is a shortcut for .Matches().Str(0)
Console.WriteLine(t.Transform("This sentence is just a test").Str(0))
End Sub
End Module
'a test' is part of: 'This sentence is just a test' Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("a test", "'{@Self}' is part of: '{@Doc}'") '// Note: .Str(0) here is a shortcut for .Matches().Str(0) Console.WriteLine(t.Transform("This sentence is just a test").Str(0)) End Sub End Module
{@Eval}, {@@Eval}, and escaping special characters in a pattern
ID: 201
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("'['{word}']'", "{@Eval: UCase(word)}");
t.FromTo("'{'{expr}'}'", "{@@Eval: expr}");
Console.WriteLine(t.Transform("Words like [this] and [that]."));
Console.WriteLine(t.Transform("Is {5*3} bigger than {5^3}?"));
Words like THIS and THAT.
Is 15 bigger than 125? using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("'['{word}']'", "{@Eval: UCase(word)}"); t.FromTo("'{'{expr}'}'", "{@@Eval: expr}"); Console.WriteLine(t.Transform("Words like [this] and [that].")); Console.WriteLine(t.Transform("Is {5*3} bigger than {5^3}?"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("'['{word}']'", "{@Eval: UCase(word)}");
t.FromTo("'{'{expr}'}'", "{@@Eval: expr}");
cout << t.Transform("Words like [this] and [that].") << endl;
cout << t.Transform("Is {5*3} bigger than {5^3}?") << endl;
}
Words like THIS and THAT.
Is 15 bigger than 125? #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("'['{word}']'", "{@Eval: UCase(word)}"); t.FromTo("'{'{expr}'}'", "{@@Eval: expr}"); cout << t.Transform("Words like [this] and [that].") << endl; cout << t.Transform("Is {5*3} bigger than {5^3}?") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("'['{word}']'", "{@Eval: UCase(word)}")
t.FromTo("'{'{expr}'}'", "{@@Eval: expr}")
Console.WriteLine(t.Transform("Words like [this] and [that]."))
Console.WriteLine(t.Transform("Is {5*3} bigger than {5^3}?"))
End Sub
End Module
Words like THIS and THAT.
Is 15 bigger than 125? Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("'['{word}']'", "{@Eval: UCase(word)}") t.FromTo("'{'{expr}'}'", "{@@Eval: expr}") Console.WriteLine(t.Transform("Words like [this] and [that].")) Console.WriteLine(t.Transform("Is {5*3} bigger than {5^3}?")) End Sub End Module
{@Exec}
ID: 216
See: {@Exec}
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Pattern("{@Define: Var: Count_a = 0}");
t.Pattern("{@Define: Var: Count_an = 0}");
t.FromTo("a", "{@Self}{@Exec: Count_a++}");
t.FromTo("an", "{@Self}{@Exec: Count_an++}");
t.FromTo(".", """
{@nl}'a' occurs {@Eval: Count_a} times
'an' occurs {@Eval: Count_an} times
""");
// Note: it is counting "a" as a token, not as a character.
Console.WriteLine(t.Transform("An apple, an eagle, a cat, an orange, a tree."));
An apple, an eagle, a cat, an orange, a tree
'a' occurs 2 times
'an' occurs 3 times using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Pattern("{@Define: Var: Count_a = 0}"); t.Pattern("{@Define: Var: Count_an = 0}"); t.FromTo("a", "{@Self}{@Exec: Count_a++}"); t.FromTo("an", "{@Self}{@Exec: Count_an++}"); t.FromTo(".", """ {@nl}'a' occurs {@Eval: Count_a} times 'an' occurs {@Eval: Count_an} times """); // Note: it is counting "a" as a token, not as a character. Console.WriteLine(t.Transform("An apple, an eagle, a cat, an orange, a tree."));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.Pattern("{@Define: Var: Count_a = 0}");
t.Pattern("{@Define: Var: Count_an = 0}");
t.FromTo("a", "{@Self}{@Exec: Count_a++}");
t.FromTo("an", "{@Self}{@Exec: Count_an++}");
t.FromTo(".", R"({@nl}'a' occurs {@Eval: Count_a} times
'an' occurs {@Eval: Count_an} times)");
// Note: it is counting "a" as a token, not as a character.
cout << t.Transform("An apple, an eagle, a cat, an orange, a tree.") << endl;
}
An apple, an eagle, a cat, an orange, a tree
'a' occurs 2 times
'an' occurs 3 times #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.Pattern("{@Define: Var: Count_a = 0}"); t.Pattern("{@Define: Var: Count_an = 0}"); t.FromTo("a", "{@Self}{@Exec: Count_a++}"); t.FromTo("an", "{@Self}{@Exec: Count_an++}"); t.FromTo(".", R"({@nl}'a' occurs {@Eval: Count_a} times 'an' occurs {@Eval: Count_an} times)"); // Note: it is counting "a" as a token, not as a character. cout << t.Transform("An apple, an eagle, a cat, an orange, a tree.") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.Pattern("{@Define: Var: Count_a = 0}")
t.Pattern("{@Define: Var: Count_an = 0}")
t.FromTo("a", "{@Self}{@Exec: Count_a++}")
t.FromTo("an", "{@Self}{@Exec: Count_an++}")
t.FromTo(".", "{@nl}'a' occurs {@Eval: Count_a} times
'an' occurs {@Eval: Count_an} times")
'// Note: it is counting "a" as a token, not as a character.
Console.WriteLine(t.Transform("An apple, an eagle, a cat, an orange, a tree."))
End Sub
End Module
An apple, an eagle, a cat, an orange, a tree
'a' occurs 2 times
'an' occurs 3 times Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.Pattern("{@Define: Var: Count_a = 0}") t.Pattern("{@Define: Var: Count_an = 0}") t.FromTo("a", "{@Self}{@Exec: Count_a++}") t.FromTo("an", "{@Self}{@Exec: Count_an++}") t.FromTo(".", "{@nl}'a' occurs {@Eval: Count_a} times 'an' occurs {@Eval: Count_an} times") '// Note: it is counting "a" as a token, not as a character. Console.WriteLine(t.Transform("An apple, an eagle, a cat, an orange, a tree.")) End Sub End Module
{@Param}
ID: 208
See: {@Param}
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("This {etc} big test {words:2}",
"{@Param:0}:{@Param:1}:{@Param:1+1}:{@Param:2+1}:{@Param:2*2}");
Console.WriteLine(t.Transform("This is a big test we have today"));
This:is a:big:test:we have today using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("This {etc} big test {words:2}", "{@Param:0}:{@Param:1}:{@Param:1+1}:{@Param:2+1}:{@Param:2*2}"); Console.WriteLine(t.Transform("This is a big test we have today"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("This {etc} big test {words:2}",
"{@Param:0}:{@Param:1}:{@Param:1+1}:{@Param:2+1}:{@Param:2*2}");
cout << t.Transform("This is a big test we have today") << endl;
}
This:is a:big:test:we have today #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("This {etc} big test {words:2}", "{@Param:0}:{@Param:1}:{@Param:1+1}:{@Param:2+1}:{@Param:2*2}"); cout << t.Transform("This is a big test we have today") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("This {etc} big test {words:2}",
"{@Param:0}:{@Param:1}:{@Param:1+1}:{@Param:2+1}:{@Param:2*2}")
Console.WriteLine(t.Transform("This is a big test we have today"))
End Sub
End Module
This:is a:big:test:we have today Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("This {etc} big test {words:2}", "{@Param:0}:{@Param:1}:{@Param:1+1}:{@Param:2+1}:{@Param:2*2}") Console.WriteLine(t.Transform("This is a big test we have today")) End Sub End Module
{@StatementSeparator}
ID: 184
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("{@StatementSeparator}", "");
Console.WriteLine(t.Transform("a = b + c; x = y + 1;"));
a = b + c<sep> x = y + 1<sep> using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("{@StatementSeparator}", "<sep>"); Console.WriteLine(t.Transform("a = b + c; x = y + 1;"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("{@StatementSeparator}", "");
cout << t.Transform("a = b + c; x = y + 1;") << endl;
}
a = b + c<sep> x = y + 1<sep> #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("{@StatementSeparator}", "<sep>"); cout << t.Transform("a = b + c; x = y + 1;") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("{@StatementSeparator}", "")
Console.WriteLine(t.Transform("a = b + c; x = y + 1;"))
End Sub
End Module
a = b + c<sep> x = y + 1<sep> Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("{@StatementSeparator}", "<sep>") Console.WriteLine(t.Transform("a = b + c; x = y + 1;")) End Sub End Module
{@Stop}
ID: 209
See: {@Stop}
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
// without {@Stop} "end" wouldn't be a match
t.FromTo("StopAt {abc} {@Stop} end", "<{abc}>");
t.FromTo("end", "[The End]");
Console.WriteLine(t.Transform("StopAt a b c end"));
<a b c> [The End] using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // without {@Stop} "end" wouldn't be a match t.FromTo("StopAt {abc} {@Stop} end", "<{abc}>"); t.FromTo("end", "[The End]"); Console.WriteLine(t.Transform("StopAt a b c end"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
// without {@Stop} "end" wouldn't be a match
t.FromTo("StopAt {abc} {@Stop} end", "<{abc}>");
t.FromTo("end", "[The End]");
cout << t.Transform("StopAt a b c end") << endl;
}
<a b c> [The End] #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); // without {@Stop} "end" wouldn't be a match t.FromTo("StopAt {abc} {@Stop} end", "<{abc}>"); t.FromTo("end", "[The End]"); cout << t.Transform("StopAt a b c end") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
'// without {@Stop} "end" wouldn't be a match
t.FromTo("StopAt {abc} {@Stop} end", "<{abc}>")
t.FromTo("end", "[The End]")
Console.WriteLine(t.Transform("StopAt a b c end"))
End Sub
End Module
<a b c> [The End] Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() '// without {@Stop} "end" wouldn't be a match t.FromTo("StopAt {abc} {@Stop} end", "<{abc}>") t.FromTo("end", "[The End]") Console.WriteLine(t.Transform("StopAt a b c end")) End Sub End Module
{@Token} - matching a token by name
ID: 185
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("{@String}", "");
t.FromTo("({@Token(String_Singlequoted)})", "");
t.FromTo("({@Token(String_Doublequoted)})", "");
var s = """
"Test" '123' ("abc") ('xyz')
""";
Console.WriteLine(t.Transform(s));
<Any quoted "Test"> <Any quoted '123'> <Double quoted ("abc")> <Single quoted ('xyz')> using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("{@String}", "<Any quoted {@Self}>"); t.FromTo("({@Token(String_Singlequoted)})", "<Single quoted {@Self}>"); t.FromTo("({@Token(String_Doublequoted)})", "<Double quoted {@Self}>"); var s = """ "Test" '123' ("abc") ('xyz') """; Console.WriteLine(t.Transform(s));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("{@String}", "");
t.FromTo("({@Token(String_Singlequoted)})", "");
t.FromTo("({@Token(String_Doublequoted)})", "");
auto s = R"("Test" '123' ("abc") ('xyz'))";
cout << t.Transform(s) << endl;
}
<Any quoted "Test"> <Any quoted '123'> <Double quoted ("abc")> <Single quoted ('xyz')> #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("{@String}", "<Any quoted {@Self}>"); t.FromTo("({@Token(String_Singlequoted)})", "<Single quoted {@Self}>"); t.FromTo("({@Token(String_Doublequoted)})", "<Double quoted {@Self}>"); auto s = R"("Test" '123' ("abc") ('xyz'))"; cout << t.Transform(s) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("{@String}", "")
t.FromTo("({@Token(String_Singlequoted)})", "")
t.FromTo("({@Token(String_Doublequoted)})", "")
Dim s = """Test"" '123' (""abc"") ('xyz')"
Console.WriteLine(t.Transform(s))
End Sub
End Module
<Any quoted "Test"> <Any quoted '123'> <Double quoted ("abc")> <Single quoted ('xyz')> Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("{@String}", "<Any quoted {@Self}>") t.FromTo("({@Token(String_Singlequoted)})", "<Single quoted {@Self}>") t.FromTo("({@Token(String_Doublequoted)})", "<Double quoted {@Self}>") Dim s = """Test"" '123' (""abc"") ('xyz')" Console.WriteLine(t.Transform(s)) End Sub End Module
{@Whitespace}
ID: 179
See: {@Whitespace}, Introduction
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("{@Whitespace}", ",");
Console.WriteLine(t.Transform("This is a 'small test' about ' whitespace ' tokens."));
This,is,a,'small test',about,' whitespace ',tokens. using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("{@Whitespace}", ","); Console.WriteLine(t.Transform("This is a 'small test' about ' whitespace ' tokens."));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("{@Whitespace}", ",");
cout << t.Transform("This is a 'small test' about ' whitespace ' tokens.") << endl;
}
This,is,a,'small test',about,' whitespace ',tokens. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("{@Whitespace}", ","); cout << t.Transform("This is a 'small test' about ' whitespace ' tokens.") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("{@Whitespace}", ",")
Console.WriteLine(t.Transform("This is a 'small test' about ' whitespace ' tokens."))
End Sub
End Module
This,is,a,'small test',about,' whitespace ',tokens. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("{@Whitespace}", ",") Console.WriteLine(t.Transform("This is a 'small test' about ' whitespace ' tokens.")) End Sub End Module
A 'Hello, World!' example demonstrating the creation and evaluation of an expression using the modern, simplified syntax.
ID: 1176
using uCalcSoftware;
var uc = new uCalc();
// Create a new Expression object with an initial formula.
// This uses the default uCalc instance for context.
var expr = new uCalc.Expression("1 + 1");
// Implicitly calls .EvaluateStr() when used in a string context
Console.WriteLine($"Initial value: {expr}");
// Reassign the expression to a new formula with a simple string assignment.
// This implicitly calls .Parse() behind the scenes.
expr = "10 * (5 + 3)";
// Retrieve the result. For numeric results, you can assign it
// directly to a double. This implicitly calls .Evaluate().
double result = expr;
Console.Write("New value: "); Console.Write(result);
Initial value: 2
New value: 80 using uCalcSoftware; var uc = new uCalc(); // Create a new Expression object with an initial formula. // This uses the default uCalc instance for context. var expr = new uCalc.Expression("1 + 1"); // Implicitly calls .EvaluateStr() when used in a string context Console.WriteLine($"Initial value: {expr}"); // Reassign the expression to a new formula with a simple string assignment. // This implicitly calls .Parse() behind the scenes. expr = "10 * (5 + 3)"; // Retrieve the result. For numeric results, you can assign it // directly to a double. This implicitly calls .Evaluate(). double result = expr; Console.Write("New value: "); Console.Write(result);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Create a new Expression object with an initial formula.
// This uses the default uCalc instance for context.
uCalc::Expression expr("1 + 1");
// Implicitly calls .EvaluateStr() when used in a string context
cout << "Initial value: " << expr << endl;
// Reassign the expression to a new formula with a simple string assignment.
// This implicitly calls .Parse() behind the scenes.
expr = "10 * (5 + 3)";
// Retrieve the result. For numeric results, you can assign it
// directly to a double. This implicitly calls .Evaluate().
double result = expr;
cout << "New value: " << result;
}
Initial value: 2
New value: 80 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Create a new Expression object with an initial formula. // This uses the default uCalc instance for context. uCalc::Expression expr("1 + 1"); // Implicitly calls .EvaluateStr() when used in a string context cout << "Initial value: " << expr << endl; // Reassign the expression to a new formula with a simple string assignment. // This implicitly calls .Parse() behind the scenes. expr = "10 * (5 + 3)"; // Retrieve the result. For numeric results, you can assign it // directly to a double. This implicitly calls .Evaluate(). double result = expr; cout << "New value: " << result; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Create a new Expression object with an initial formula.
'// This uses the default uCalc instance for context.
Dim expr As New uCalc.Expression("1 + 1")
'// Implicitly calls .EvaluateStr() when used in a string context
Console.WriteLine($"Initial value: {expr}")
'// Reassign the expression to a new formula with a simple string assignment.
'// This implicitly calls .Parse() behind the scenes.
expr = "10 * (5 + 3)"
'// Retrieve the result. For numeric results, you can assign it
'// directly to a double. This implicitly calls .Evaluate().
Dim result As Double = expr
Console.Write("New value: ")
Console.Write(result)
End Sub
End Module
Initial value: 2
New value: 80 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Create a new Expression object with an initial formula. '// This uses the default uCalc instance for context. Dim expr As New uCalc.Expression("1 + 1") '// Implicitly calls .EvaluateStr() when used in a string context Console.WriteLine($"Initial value: {expr}") '// Reassign the expression to a new formula with a simple string assignment. '// This implicitly calls .Parse() behind the scenes. expr = "10 * (5 + 3)" '// Retrieve the result. For numeric results, you can assign it '// directly to a double. This implicitly calls .Evaluate(). Dim result As Double = expr Console.Write("New value: ") Console.Write(result) End Sub End Module
A basic demonstration of how the Maximum threshold invalidates a rule's matches.
ID: 945
See: Maximum = [int]
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
var ruleA = t.FromTo("a", "A");
// Case 1: Limit is 2, but 3 'a's are present. The rule is invalidated.
t.Transform("a b a c a");
ruleA.Maximum = 2;
Console.WriteLine("--- Maximum = 2 (Rule Fails) ---");
Console.Write("Result: ");
Console.WriteLine(t.Transform("a b a c a"));
// Case 2: Limit is 3. The rule passes and matches are kept.
ruleA.Maximum = 3;
Console.WriteLine("");
Console.WriteLine("--- Maximum = 3 (Rule Succeeds) ---");
Console.Write("Result: ");
Console.WriteLine(t.Transform("a b a c a"));
--- Maximum = 2 (Rule Fails) ---
Result: a b a c a
--- Maximum = 3 (Rule Succeeds) ---
Result: A b A c A using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); var ruleA = t.FromTo("a", "A"); // Case 1: Limit is 2, but 3 'a's are present. The rule is invalidated. t.Transform("a b a c a"); ruleA.Maximum = 2; Console.WriteLine("--- Maximum = 2 (Rule Fails) ---"); Console.Write("Result: "); Console.WriteLine(t.Transform("a b a c a")); // Case 2: Limit is 3. The rule passes and matches are kept. ruleA.Maximum = 3; Console.WriteLine(""); Console.WriteLine("--- Maximum = 3 (Rule Succeeds) ---"); Console.Write("Result: "); Console.WriteLine(t.Transform("a b a c a"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
auto ruleA = t.FromTo("a", "A");
// Case 1: Limit is 2, but 3 'a's are present. The rule is invalidated.
t.Transform("a b a c a");
ruleA.Maximum(2);
cout << "--- Maximum = 2 (Rule Fails) ---" << endl;
cout << "Result: ";
cout << t.Transform("a b a c a") << endl;
// Case 2: Limit is 3. The rule passes and matches are kept.
ruleA.Maximum(3);
cout << "" << endl;
cout << "--- Maximum = 3 (Rule Succeeds) ---" << endl;
cout << "Result: ";
cout << t.Transform("a b a c a") << endl;
}
--- Maximum = 2 (Rule Fails) ---
Result: a b a c a
--- Maximum = 3 (Rule Succeeds) ---
Result: A b A c A #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); auto ruleA = t.FromTo("a", "A"); // Case 1: Limit is 2, but 3 'a's are present. The rule is invalidated. t.Transform("a b a c a"); ruleA.Maximum(2); cout << "--- Maximum = 2 (Rule Fails) ---" << endl; cout << "Result: "; cout << t.Transform("a b a c a") << endl; // Case 2: Limit is 3. The rule passes and matches are kept. ruleA.Maximum(3); cout << "" << endl; cout << "--- Maximum = 3 (Rule Succeeds) ---" << endl; cout << "Result: "; cout << t.Transform("a b a c a") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
Dim ruleA = t.FromTo("a", "A")
'// Case 1: Limit is 2, but 3 'a's are present. The rule is invalidated.
t.Transform("a b a c a")
ruleA.Maximum = 2
Console.WriteLine("--- Maximum = 2 (Rule Fails) ---")
Console.Write("Result: ")
Console.WriteLine(t.Transform("a b a c a"))
'// Case 2: Limit is 3. The rule passes and matches are kept.
ruleA.Maximum = 3
Console.WriteLine("")
Console.WriteLine("--- Maximum = 3 (Rule Succeeds) ---")
Console.Write("Result: ")
Console.WriteLine(t.Transform("a b a c a"))
End Sub
End Module
--- Maximum = 2 (Rule Fails) ---
Result: a b a c a
--- Maximum = 3 (Rule Succeeds) ---
Result: A b A c A Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() Dim ruleA = t.FromTo("a", "A") '// Case 1: Limit is 2, but 3 'a's are present. The rule is invalidated. t.Transform("a b a c a") ruleA.Maximum = 2 Console.WriteLine("--- Maximum = 2 (Rule Fails) ---") Console.Write("Result: ") Console.WriteLine(t.Transform("a b a c a")) '// Case 2: Limit is 3. The rule passes and matches are kept. ruleA.Maximum = 3 Console.WriteLine("") Console.WriteLine("--- Maximum = 3 (Rule Succeeds) ---") Console.Write("Result: ") Console.WriteLine(t.Transform("a b a c a")) End Sub End Module
A basic demonstration of toggling the Focusable flag to filter a list of matches.
ID: 874
See: Focusable = [bool]
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "A B C";
var ruleA = t.Pattern("A").SetFocusable(true);
var ruleB = t.Pattern("B").SetFocusable(true);
var ruleC = t.Pattern("C").SetFocusable(false); // C is not focusable
t.Find();
Console.WriteLine("--- All Matches ---");
Console.WriteLine(t.GetMatches(MatchesOption.All).Text);
Console.Write("--- Focusable Matches ---");
// This list will exclude the match for 'C'.
Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text);
--- All Matches ---
A
B
C
--- Focusable Matches ---A
B using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Text = "A B C"; var ruleA = t.Pattern("A").SetFocusable(true); var ruleB = t.Pattern("B").SetFocusable(true); var ruleC = t.Pattern("C").SetFocusable(false); // C is not focusable t.Find(); Console.WriteLine("--- All Matches ---"); Console.WriteLine(t.GetMatches(MatchesOption.All).Text); Console.Write("--- Focusable Matches ---"); // This list will exclude the match for 'C'. Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.Text("A B C");
auto ruleA = t.Pattern("A").SetFocusable(true);
auto ruleB = t.Pattern("B").SetFocusable(true);
auto ruleC = t.Pattern("C").SetFocusable(false); // C is not focusable
t.Find();
cout << "--- All Matches ---" << endl;
cout << t.GetMatches(MatchesOption::All).Text() << endl;
cout << "--- Focusable Matches ---";
// This list will exclude the match for 'C'.
cout << t.GetMatches(MatchesOption::FocusableOnly).Text() << endl;
}
--- All Matches ---
A
B
C
--- Focusable Matches ---A
B #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.Text("A B C"); auto ruleA = t.Pattern("A").SetFocusable(true); auto ruleB = t.Pattern("B").SetFocusable(true); auto ruleC = t.Pattern("C").SetFocusable(false); // C is not focusable t.Find(); cout << "--- All Matches ---" << endl; cout << t.GetMatches(MatchesOption::All).Text() << endl; cout << "--- Focusable Matches ---"; // This list will exclude the match for 'C'. cout << t.GetMatches(MatchesOption::FocusableOnly).Text() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.Text = "A B C"
Dim ruleA = t.Pattern("A").SetFocusable(true)
Dim ruleB = t.Pattern("B").SetFocusable(true)
Dim ruleC = t.Pattern("C").SetFocusable(false) '// C is not focusable
t.Find()
Console.WriteLine("--- All Matches ---")
Console.WriteLine(t.GetMatches(MatchesOption.All).Text)
Console.Write("--- Focusable Matches ---")
'// This list will exclude the match for 'C'.
Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text)
End Sub
End Module
--- All Matches ---
A
B
C
--- Focusable Matches ---A
B Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.Text = "A B C" Dim ruleA = t.Pattern("A").SetFocusable(true) Dim ruleB = t.Pattern("B").SetFocusable(true) Dim ruleC = t.Pattern("C").SetFocusable(false) '// C is not focusable t.Find() Console.WriteLine("--- All Matches ---") Console.WriteLine(t.GetMatches(MatchesOption.All).Text) Console.Write("--- Focusable Matches ---") '// This list will exclude the match for 'C'. Console.WriteLine(t.GetMatches(MatchesOption.FocusableOnly).Text) End Sub End Module
A basic example demonstrating how to ignore a block of text in parentheses, preventing other rules from matching inside it.
ID: 1210
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.FromTo("word", "WORD"); // Rule to uppercase 'word'
t.SkipOver("({ignore})"); // Rule to ignore content in parentheses
var text = "transform this word, but (not this word)";
Console.WriteLine(t.Transform(text));
transform this WORD, but (not this word) using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.FromTo("word", "WORD"); // Rule to uppercase 'word' t.SkipOver("({ignore})"); // Rule to ignore content in parentheses var text = "transform this word, but (not this word)"; Console.WriteLine(t.Transform(text));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.FromTo("word", "WORD"); // Rule to uppercase 'word'
t.SkipOver("({ignore})"); // Rule to ignore content in parentheses
auto text = "transform this word, but (not this word)";
cout << t.Transform(text) << endl;
}
transform this WORD, but (not this word) #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.FromTo("word", "WORD"); // Rule to uppercase 'word' t.SkipOver("({ignore})"); // Rule to ignore content in parentheses auto text = "transform this word, but (not this word)"; cout << t.Transform(text) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.FromTo("word", "WORD") '// Rule to uppercase 'word'
t.SkipOver("({ignore})") '// Rule to ignore content in parentheses
Dim text = "transform this word, but (not this word)"
Console.WriteLine(t.Transform(text))
End Sub
End Module
transform this WORD, but (not this word) Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.FromTo("word", "WORD") '// Rule to uppercase 'word' t.SkipOver("({ignore})") '// Rule to ignore content in parentheses Dim text = "transform this word, but (not this word)" Console.WriteLine(t.Transform(text)) End Sub End Module
A basic example demonstrating how to set and get a description for a Transformer.
ID: 1062
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.Description = "My First Transformer";
Console.WriteLine($"Transformer Description: {t.Description}");
Transformer Description: My First Transformer using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.Description = "My First Transformer"; Console.WriteLine($"Transformer Description: {t.Description}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.Description("My First Transformer");
cout << "Transformer Description: " << t.Description() << endl;
}
Transformer Description: My First Transformer #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.Description("My First Transformer"); cout << "Transformer Description: " << t.Description() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.Description = "My First Transformer"
Console.WriteLine($"Transformer Description: {t.Description}")
End Sub
End Module
Transformer Description: My First Transformer Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.Description = "My First Transformer" Console.WriteLine($"Transformer Description: {t.Description}") End Sub End Module
A basic example of defining a variable and using it in an expression.
ID: 1180
using uCalcSoftware;
var uc = new uCalc();
uc.DefineVariable("x = 10");
Console.WriteLine(uc.EvalStr("x * 5"));
50 using uCalcSoftware; var uc = new uCalc(); uc.DefineVariable("x = 10"); Console.WriteLine(uc.EvalStr("x * 5"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uc.DefineVariable("x = 10");
cout << uc.EvalStr("x * 5") << endl;
}
50 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uc.DefineVariable("x = 10"); cout << uc.EvalStr("x * 5") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
uc.DefineVariable("x = 10")
Console.WriteLine(uc.EvalStr("x * 5"))
End Sub
End Module
50 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() uc.DefineVariable("x = 10") Console.WriteLine(uc.EvalStr("x * 5")) End Sub End Module
A basic example of setting the text, transforming it, and retrieving the result.
ID: 1132
See: Text = [string]
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
// 1. Set the initial text
t.Text = "The quick brown fox.";
// 2. Define a rule and transform
t.FromTo("brown", "red");
t.Transform();
// 3. Get the final text
Console.WriteLine(t.Text);
The quick red fox. using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); // 1. Set the initial text t.Text = "The quick brown fox."; // 2. Define a rule and transform t.FromTo("brown", "red"); t.Transform(); // 3. Get the final text Console.WriteLine(t.Text);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
// 1. Set the initial text
t.Text("The quick brown fox.");
// 2. Define a rule and transform
t.FromTo("brown", "red");
t.Transform();
// 3. Get the final text
cout << t.Text() << endl;
}
The quick red fox. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; // 1. Set the initial text t.Text("The quick brown fox."); // 2. Define a rule and transform t.FromTo("brown", "red"); t.Transform(); // 3. Get the final text cout << t.Text() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
'// 1. Set the initial text
t.Text = "The quick brown fox."
'// 2. Define a rule and transform
t.FromTo("brown", "red")
t.Transform()
'// 3. Get the final text
Console.WriteLine(t.Text)
End Sub
End Module
The quick red fox. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() '// 1. Set the initial text t.Text = "The quick brown fox." '// 2. Define a rule and transform t.FromTo("brown", "red") t.Transform() '// 3. Get the final text Console.WriteLine(t.Text) End Sub End Module
A basic example that prepends text to all numeric output.
ID: 351
using uCalcSoftware;
var uc = new uCalc();
// Define a format that only applies to Double data types.
var doubleType = uc.DataTypeOf("Double");
var fmt = uc.Format("Result = 'Value: ' + Result", doubleType);
Console.WriteLine(uc.EvalStr("10 * 2.5"));
Console.WriteLine(uc.EvalStr("'Hello'")); // String output is unaffected.
// Clean up the format rule
fmt.Release();
Console.WriteLine(uc.EvalStr("10 * 2.5")); // No longer formatted
Value: 25
Hello
25 using uCalcSoftware; var uc = new uCalc(); // Define a format that only applies to Double data types. var doubleType = uc.DataTypeOf("Double"); var fmt = uc.Format("Result = 'Value: ' + Result", doubleType); Console.WriteLine(uc.EvalStr("10 * 2.5")); Console.WriteLine(uc.EvalStr("'Hello'")); // String output is unaffected. // Clean up the format rule fmt.Release(); Console.WriteLine(uc.EvalStr("10 * 2.5")); // No longer formatted
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Define a format that only applies to Double data types.
auto doubleType = uc.DataTypeOf("Double");
auto fmt = uc.Format("Result = 'Value: ' + Result", doubleType);
cout << uc.EvalStr("10 * 2.5") << endl;
cout << uc.EvalStr("'Hello'") << endl; // String output is unaffected.
// Clean up the format rule
fmt.Release();
cout << uc.EvalStr("10 * 2.5") << endl; // No longer formatted
}
Value: 25
Hello
25 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Define a format that only applies to Double data types. auto doubleType = uc.DataTypeOf("Double"); auto fmt = uc.Format("Result = 'Value: ' + Result", doubleType); cout << uc.EvalStr("10 * 2.5") << endl; cout << uc.EvalStr("'Hello'") << endl; // String output is unaffected. // Clean up the format rule fmt.Release(); cout << uc.EvalStr("10 * 2.5") << endl; // No longer formatted }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Define a format that only applies to Double data types.
Dim doubleType = uc.DataTypeOf("Double")
Dim fmt = uc.Format("Result = 'Value: ' + Result", doubleType)
Console.WriteLine(uc.EvalStr("10 * 2.5"))
Console.WriteLine(uc.EvalStr("'Hello'")) '// String output is unaffected.
'// Clean up the format rule
fmt.Release()
Console.WriteLine(uc.EvalStr("10 * 2.5")) '// No longer formatted
End Sub
End Module
Value: 25
Hello
25 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Define a format that only applies to Double data types. Dim doubleType = uc.DataTypeOf("Double") Dim fmt = uc.Format("Result = 'Value: ' + Result", doubleType) Console.WriteLine(uc.EvalStr("10 * 2.5")) Console.WriteLine(uc.EvalStr("'Hello'")) '// String output is unaffected. '// Clean up the format rule fmt.Release() Console.WriteLine(uc.EvalStr("10 * 2.5")) '// No longer formatted End Sub End Module