Uses descriptions to identify and differentiate between two separate token configurations at runtime.
ID: 1034
using uCalcSoftware;
var uc = new uCalc();
// Create two transformers with different token configurations
var strict_t = new uCalc.Transformer();
strict_t.Tokens.Description = "Strict Mode: only 'is' as a whole word.";
var flexible_t = new uCalc.Transformer();
flexible_t.Tokens.Description = "Flexible Mode: matches 'is' inside other words.";
flexible_t.Tokens.Clear();
flexible_t.Tokens.Add("."); // Match by character
string text = "This island is nice.";
strict_t.FromTo("is", "[MATCH]");
flexible_t.FromTo("is", "[MATCH]");
Console.WriteLine(strict_t.Tokens.Description);
Console.WriteLine($"Result: {strict_t.Transform(text)}");
Console.WriteLine("");
Console.WriteLine(flexible_t.Tokens.Description);
Console.WriteLine($"Result: {flexible_t.Transform(text)}");
Strict Mode: only 'is' as a whole word.
Result: This island [MATCH] nice.
Flexible Mode: matches 'is' inside other words.
Result: Th[MATCH] [MATCH]land [MATCH] nice. using uCalcSoftware; var uc = new uCalc(); // Create two transformers with different token configurations var strict_t = new uCalc.Transformer(); strict_t.Tokens.Description = "Strict Mode: only 'is' as a whole word."; var flexible_t = new uCalc.Transformer(); flexible_t.Tokens.Description = "Flexible Mode: matches 'is' inside other words."; flexible_t.Tokens.Clear(); flexible_t.Tokens.Add("."); // Match by character string text = "This island is nice."; strict_t.FromTo("is", "[MATCH]"); flexible_t.FromTo("is", "[MATCH]"); Console.WriteLine(strict_t.Tokens.Description); Console.WriteLine($"Result: {strict_t.Transform(text)}"); Console.WriteLine(""); Console.WriteLine(flexible_t.Tokens.Description); Console.WriteLine($"Result: {flexible_t.Transform(text)}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Create two transformers with different token configurations
uCalc::Transformer strict_t;
strict_t.Tokens().Description("Strict Mode: only 'is' as a whole word.");
uCalc::Transformer flexible_t;
flexible_t.Tokens().Description("Flexible Mode: matches 'is' inside other words.");
flexible_t.Tokens().Clear();
flexible_t.Tokens().Add("."); // Match by character
string text = "This island is nice.";
strict_t.FromTo("is", "[MATCH]");
flexible_t.FromTo("is", "[MATCH]");
cout << strict_t.Tokens().Description() << endl;
cout << "Result: " << strict_t.Transform(text) << endl;
cout << "" << endl;
cout << flexible_t.Tokens().Description() << endl;
cout << "Result: " << flexible_t.Transform(text) << endl;
}
Strict Mode: only 'is' as a whole word.
Result: This island [MATCH] nice.
Flexible Mode: matches 'is' inside other words.
Result: Th[MATCH] [MATCH]land [MATCH] nice. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Create two transformers with different token configurations uCalc::Transformer strict_t; strict_t.Tokens().Description("Strict Mode: only 'is' as a whole word."); uCalc::Transformer flexible_t; flexible_t.Tokens().Description("Flexible Mode: matches 'is' inside other words."); flexible_t.Tokens().Clear(); flexible_t.Tokens().Add("."); // Match by character string text = "This island is nice."; strict_t.FromTo("is", "[MATCH]"); flexible_t.FromTo("is", "[MATCH]"); cout << strict_t.Tokens().Description() << endl; cout << "Result: " << strict_t.Transform(text) << endl; cout << "" << endl; cout << flexible_t.Tokens().Description() << endl; cout << "Result: " << flexible_t.Transform(text) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Create two transformers with different token configurations
Dim strict_t As New uCalc.Transformer()
strict_t.Tokens.Description = "Strict Mode: only 'is' as a whole word."
Dim flexible_t As New uCalc.Transformer()
flexible_t.Tokens.Description = "Flexible Mode: matches 'is' inside other words."
flexible_t.Tokens.Clear()
flexible_t.Tokens.Add(".") '// Match by character
Dim text As String = "This island is nice."
strict_t.FromTo("is", "[MATCH]")
flexible_t.FromTo("is", "[MATCH]")
Console.WriteLine(strict_t.Tokens.Description)
Console.WriteLine($"Result: {strict_t.Transform(text)}")
Console.WriteLine("")
Console.WriteLine(flexible_t.Tokens.Description)
Console.WriteLine($"Result: {flexible_t.Transform(text)}")
End Sub
End Module
Strict Mode: only 'is' as a whole word.
Result: This island [MATCH] nice.
Flexible Mode: matches 'is' inside other words.
Result: Th[MATCH] [MATCH]land [MATCH] nice. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Create two transformers with different token configurations Dim strict_t As New uCalc.Transformer() strict_t.Tokens.Description = "Strict Mode: only 'is' as a whole word." Dim flexible_t As New uCalc.Transformer() flexible_t.Tokens.Description = "Flexible Mode: matches 'is' inside other words." flexible_t.Tokens.Clear() flexible_t.Tokens.Add(".") '// Match by character Dim text As String = "This island is nice." strict_t.FromTo("is", "[MATCH]") flexible_t.FromTo("is", "[MATCH]") Console.WriteLine(strict_t.Tokens.Description) Console.WriteLine($"Result: {strict_t.Transform(text)}") Console.WriteLine("") Console.WriteLine(flexible_t.Tokens.Description) Console.WriteLine($"Result: {flexible_t.Transform(text)}") End Sub End Module