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.

Escapes

Product: 

Class: 

Remarks

uCalc patterns reserve certain characters for syntax ({, }, [, ], |). To match these characters literally in your text, you use the Escape Token mechanism.

User-Defined Escape System:Unlike Regex which forces \ as the escape character, uCalc allows you to define any token pattern as an escape mechanism by assigning it the TokenType.Escape category.

How it Works:

  1. Define: Register a token definition (e.g., \ or '...') with TokenType.Escape.
  2. Match: When the parser encounters this token, it "neutralizes" the special meaning of the text immediately following it (or captured within it).
  3. Output: The neutralized text is treated as a literal token.

Configuration Strategies:

  • Backslash Style: Define \\ (matches \) as an escape. \{ becomes literal {.
  • Smart Quote Style (Recommended): Define a pattern like '([\{\}\[\]\|])' to only escape specific characters inside quotes.
    • Advantage: This solves the "Apostrophe Conflict." Since the pattern only matches specific symbols inside quotes, natural language like User's is ignored by the escape token and treated as a standard word, while '{' is treated as an escape.

Capture Group Logic:If your escape token definition contains a capture group (parentheses in Regex), uCalc uses the content of the first group ($1) as the unescaped literal. If there are no groups, it uses the whole matched string.

Comparative Analysis: Why uCalc?

  • vs. Regex: Regex imposes \ as the escape. uCalc lets you adapt. If you are parsing file paths (lots of \), you can switch your escape char to ^ or % to keep patterns readable.
  • vs. SQL/Legacy: Traditional SQL uses double-quotes ('') for everything, which breaks natural language. uCalc's granular configuration allows precise targeting of reserved chars only.

Examples

{@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?
				
					#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;
}
				
			
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
				
			
Words like THIS and THAT.
Is 15 bigger than 125?