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.

Name = [string]

Property

Product: 

Class: 

Gets the programmatic name of a rule, which is automatically derived from the first non-variable token in its pattern definition.

Remarks

🎯 The Rule's Identifier: Name

The Name property provides runtime access to the programmatic name of a Rule. This identifier is not set manually; instead, it is automatically derived from the structure of the pattern string used to define the rule.

⚙️ How the Name is Derived

The name is determined by the first token in the pattern that is not a variable or a special directive. This makes the name a predictable and meaningful representation of the rule's primary anchor.

  • For a pattern like "Hello {name}", the name will be "hello".
  • For "<{tag}>;{content}</{tag}>", the name will be "<".
  • For "{@Number}: {value}", the name will be ":".

Case Normalization: By default, the derived name is converted to lowercase. This ensures that lookups and comparisons are case-insensitive, providing consistent and predictable behavior regardless of the casing used in the original pattern definition.

💡 Primary Use Cases

  • Debugging & Introspection: When iterating through a Transformer's collection of rules or a list of Matches, you can retrieve a rule's name to log or display which pattern was responsible for a specific action.
  • Dynamic Rule Management: Retrieve a specific rule by its derived name from the Transformer's rule collection to modify or inspect it programmatically.

🆚 Comparative Analysis

This feature provides a unique advantage over traditional Regex engines.

  • vs. Regex Named Capture Groups: In Regex, you must explicitly name parts of your pattern (e.g., (?<myGroup>...)). uCalc's Rule.Name is different; it's an automatically generated identifier for the rule itself, derived from its structure. This provides a zero-effort way to get a meaningful handle for every pattern you define, simplifying debugging and introspection.

Examples

A simple demonstration of how a rule's name is derived from the first token in its pattern.

ID: 951

				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();

var rule1 = t.FromTo("Hello {name}", "Hi {name}");
var rule2 = t.Pattern("<h1>{title}</h1>");

Console.WriteLine($"Rule 1 Name: '{rule1.Name}'");
Console.WriteLine($"Rule 2 Name: '{rule2.Name}'");
				
			
Rule 1 Name: 'hello'
Rule 2 Name: '<'
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;

   auto rule1 = t.FromTo("Hello {name}", "Hi {name}");
   auto rule2 = t.Pattern("<h1>{title}</h1>");

   cout << "Rule 1 Name: '" << rule1.Name() << "'" << endl;
   cout << "Rule 2 Name: '" << rule2.Name() << "'" << endl;
}
				
			
Rule 1 Name: 'hello'
Rule 2 Name: '<'
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      
      Dim rule1 = t.FromTo("Hello {name}", "Hi {name}")
      Dim rule2 = t.Pattern("<h1>{title}</h1>")
      
      Console.WriteLine($"Rule 1 Name: '{rule1.Name}'")
      Console.WriteLine($"Rule 2 Name: '{rule2.Name}'")
   End Sub
End Module
				
			
Rule 1 Name: 'hello'
Rule 2 Name: '<'
A practical example showing how to iterate through all matches and print the name of the rule that generated each one for debugging.

ID: 952

				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.Text = "Log: INFO, Data: 123, Log: WARN";

// Define two rules with different starting anchors
t.Pattern("Log: {@Alpha}");
t.Pattern("Data: {@Number}");
t.Find();

Console.WriteLine("--- Match Analysis ---");
foreach(var match in t.Matches) {
   Console.WriteLine($"Match '{match.Text}' was found by rule '{match.Rule.Name}'");
}
				
			
--- Match Analysis ---
Match 'Log: INFO' was found by rule 'log'
Match 'Data: 123' was found by rule 'data'
Match 'Log: WARN' was found by rule 'log'
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   t.Text("Log: INFO, Data: 123, Log: WARN");

   // Define two rules with different starting anchors
   t.Pattern("Log: {@Alpha}");
   t.Pattern("Data: {@Number}");
   t.Find();

   cout << "--- Match Analysis ---" << endl;
   for(auto match : t.Matches()) {
      cout << "Match '" << match.Text() << "' was found by rule '" << match.Rule().Name() << "'" << endl;
   }
}
				
			
--- Match Analysis ---
Match 'Log: INFO' was found by rule 'log'
Match 'Data: 123' was found by rule 'data'
Match 'Log: WARN' was found by rule 'log'
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      t.Text = "Log: INFO, Data: 123, Log: WARN"
      
      '// Define two rules with different starting anchors
      t.Pattern("Log: {@Alpha}")
      t.Pattern("Data: {@Number}")
      t.Find()
      
      Console.WriteLine("--- Match Analysis ---")
      For Each match In t.Matches
         Console.WriteLine($"Match '{match.Text}' was found by rule '{match.Rule.Name}'")
      Next
   End Sub
End Module
				
			
--- Match Analysis ---
Match 'Log: INFO' was found by rule 'log'
Match 'Data: 123' was found by rule 'data'
Match 'Log: WARN' was found by rule 'log'
Rule Name

ID: 130

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "<b>(5+4)</b> this and that etc";
var a = t.Pattern("<{tg}>");
var b = t.Pattern("This {body} That");
var c = t.Pattern("etc");
var d = t.Pattern("({expr})");

t.Filter();
Console.WriteLine("--- Matches ---");
Console.WriteLine(t.Matches.Text);
Console.WriteLine("--- Pattern names ---");
Console.WriteLine(a.Name);
Console.WriteLine(b.Name);
Console.WriteLine(c.Name);
Console.WriteLine(d.Name);
Console.WriteLine("--- Pattern defs ---");
Console.WriteLine(a.Pattern);
Console.WriteLine(b.Pattern);
Console.WriteLine(c.Pattern);
Console.WriteLine(d.Pattern);
				
			
--- Matches ---
<b>
(5+4)
</b>
this and that
etc
--- Pattern names ---
<
this
etc
(
--- Pattern defs ---
<{tg}>
This {body} That
etc
({expr})
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.Text("<b>(5+4)</b> this and that etc");
   auto a = t.Pattern("<{tg}>");
   auto b = t.Pattern("This {body} That");
   auto c = t.Pattern("etc");
   auto d = t.Pattern("({expr})");

   t.Filter();
   cout << "--- Matches ---" << endl;
   cout << t.Matches().Text() << endl;
   cout << "--- Pattern names ---" << endl;
   cout << a.Name() << endl;
   cout << b.Name() << endl;
   cout << c.Name() << endl;
   cout << d.Name() << endl;
   cout << "--- Pattern defs ---" << endl;
   cout << a.Pattern() << endl;
   cout << b.Pattern() << endl;
   cout << c.Pattern() << endl;
   cout << d.Pattern() << endl;
}
				
			
--- Matches ---
<b>
(5+4)
</b>
this and that
etc
--- Pattern names ---
<
this
etc
(
--- Pattern defs ---
<{tg}>
This {body} That
etc
({expr})
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.Text = "<b>(5+4)</b> this and that etc"
      Dim a = t.Pattern("<{tg}>")
      Dim b = t.Pattern("This {body} That")
      Dim c = t.Pattern("etc")
      Dim d = t.Pattern("({expr})")
      
      t.Filter()
      Console.WriteLine("--- Matches ---")
      Console.WriteLine(t.Matches.Text)
      Console.WriteLine("--- Pattern names ---")
      Console.WriteLine(a.Name)
      Console.WriteLine(b.Name)
      Console.WriteLine(c.Name)
      Console.WriteLine(d.Name)
      Console.WriteLine("--- Pattern defs ---")
      Console.WriteLine(a.Pattern)
      Console.WriteLine(b.Pattern)
      Console.WriteLine(c.Pattern)
      Console.WriteLine(d.Pattern)
   End Sub
End Module
				
			
--- Matches ---
<b>
(5+4)
</b>
this and that
etc
--- Pattern names ---
<
this
etc
(
--- Pattern defs ---
<{tg}>
This {body} That
etc
({expr})