uCalc API Version: 2.1.3-preview.2 Released: 6/16/2026

Warning

uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.

{@Alphanumeric}

Product: 

Class: 

Remarks

Captures tokens categorized as Alphanumeric. This includes standard words, variable identifiers, and any text defined by the current alphanumeric tokenizer rules (typically [a-zA-Z_][a-zA-Z0-9_]*).

Remarks

The {@Alphanumeric} category matcher is used to find and optionally capture words or identifiers without needing to know their specific literal value.

  • Shortcut Syntax: The parser is not case-sensitive regarding category names and only evaluates the first letter. Therefore, {@a}, {@alpha}, and {@AlphNum} are all functionally identical to {@Alphanumeric}.

  • Variable Capture: Use the syntax {@Alphanumeric:varName} to capture the matched word into a variable for use in replacements.

  • Precedence Warning: Use caution when defining a rule consisting solely of {@Alphanumeric}. Because it matches any identifier, it may compete with and take precedence over more specific alphanumeric anchors (literals) in other patterns if not properly ordered.

Why uCalc? (Comparative Analysis)

  • vs. Regular Expressions (\w+):
    • Boundary Awareness: \w+ is a character-level match that can bleed into other tokens. {@Alphanumeric} is a token-level match; it will never capture half a word or match inside a quoted string unless configured to do so.
    • Configurability: In Regex, \w is fixed. In uCalc, you can redefine what characters are considered "alphanumeric" globally (e.g., adding hyphens or foreign characters) and {@Alphanumeric} will automatically adapt across all rules.
  • vs. AI (LLMs):
    • Determinism: An LLM might hallucinate whether a specific string (like var_123) is a "word" or a "symbol." uCalc provides a deterministic guarantee: if the tokenizer says it's alphanumeric, the pattern matches.

Examples

{@Alphanumeric}
				
					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)"));
				
			
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;
}
				
			
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
				
			
Testing 123 (456) <Alpha str=abc> ('text') <Alpha str=xyz111>
Matching by token type
				
					using uCalcSoftware;

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

t.FromTo("{@String:txt}", "<<InnerQuote={txt}><TxtWithQuotes={txt(0)}>>");
t.FromTo("{@Number:MyNum}", "<NumericValue={MyNum}>");
t.FromTo("{@Bracket:MyBrack}", "<Brack={MyBrack}>");
t.FromTo("{@CloseBracket:CloseBr}", "<CloseBrack={CloseBr}>");
t.FromTo("{@StatementSeparator:Sep}", "<Separator={Sep}>");
t.FromTo("{@Alphanumeric:alpha}", "<Alpha={alpha}>");
t.FromTo("{@Whitespace:ws}", "<whitespace count={@Eval: Length(ws)}>");
t.FromTo("{@Reducible:r}", "<Reducible={r}>");
t.FromTo("{@Newline}", "<New line{@Newline}>");

var s = """
This is   55.2*6 "Hello world";
'Single quote'(parenth)
""";

Console.WriteLine(t.Filter(s).Matches.Text);
				
			
<Alpha=This>
<whitespace count=1>
<Alpha=is>
<whitespace count=3>
<NumericValue=55.2>
<Reducible=*>
<NumericValue=6>
<whitespace count=1>
<<InnerQuote=Hello world><TxtWithQuotes="Hello world">>
<Separator=;>
<New line
>
<<InnerQuote=Single quote><TxtWithQuotes='Single quote'>>
<Brack=(>
<Alpha=parenth>
<CloseBrack=)>
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();

   t.FromTo("{@String:txt}", "<<InnerQuote={txt}><TxtWithQuotes={txt(0)}>>");
   t.FromTo("{@Number:MyNum}", "<NumericValue={MyNum}>");
   t.FromTo("{@Bracket:MyBrack}", "<Brack={MyBrack}>");
   t.FromTo("{@CloseBracket:CloseBr}", "<CloseBrack={CloseBr}>");
   t.FromTo("{@StatementSeparator:Sep}", "<Separator={Sep}>");
   t.FromTo("{@Alphanumeric:alpha}", "<Alpha={alpha}>");
   t.FromTo("{@Whitespace:ws}", "<whitespace count={@Eval: Length(ws)}>");
   t.FromTo("{@Reducible:r}", "<Reducible={r}>");
   t.FromTo("{@Newline}", "<New line{@Newline}>");

   auto s = R"(This is   55.2*6 "Hello world";
'Single quote'(parenth))";

   cout << t.Filter(s).Matches().Text() << endl;
}
				
			
<Alpha=This>
<whitespace count=1>
<Alpha=is>
<whitespace count=3>
<NumericValue=55.2>
<Reducible=*>
<NumericValue=6>
<whitespace count=1>
<<InnerQuote=Hello world><TxtWithQuotes="Hello world">>
<Separator=;>
<New line
>
<<InnerQuote=Single quote><TxtWithQuotes='Single quote'>>
<Brack=(>
<Alpha=parenth>
<CloseBrack=)>
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      
      t.FromTo("{@String:txt}", "<<InnerQuote={txt}><TxtWithQuotes={txt(0)}>>")
      t.FromTo("{@Number:MyNum}", "<NumericValue={MyNum}>")
      t.FromTo("{@Bracket:MyBrack}", "<Brack={MyBrack}>")
      t.FromTo("{@CloseBracket:CloseBr}", "<CloseBrack={CloseBr}>")
      t.FromTo("{@StatementSeparator:Sep}", "<Separator={Sep}>")
      t.FromTo("{@Alphanumeric:alpha}", "<Alpha={alpha}>")
      t.FromTo("{@Whitespace:ws}", "<whitespace count={@Eval: Length(ws)}>")
      t.FromTo("{@Reducible:r}", "<Reducible={r}>")
      t.FromTo("{@Newline}", "<New line{@Newline}>")
      
      Dim s = "This is   55.2*6 ""Hello world"";
'Single quote'(parenth)"
      
      Console.WriteLine(t.Filter(s).Matches.Text)
   End Sub
End Module
				
			
<Alpha=This>
<whitespace count=1>
<Alpha=is>
<whitespace count=3>
<NumericValue=55.2>
<Reducible=*>
<NumericValue=6>
<whitespace count=1>
<<InnerQuote=Hello world><TxtWithQuotes="Hello world">>
<Separator=;>
<New line
>
<<InnerQuote=Single quote><TxtWithQuotes='Single quote'>>
<Brack=(>
<Alpha=parenth>
<CloseBrack=)>
Extracting keys from a key-value list where keys must be identifiers.
				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
// Capture the alphanumeric key and any literal value
t.FromTo("{@Alpha:key} = {@Literal:val}", "KEY:[{key}] VAL:[{val}]");

var input = "Timeout = 100; User = 'Admin'";
Console.WriteLine(t.Transform(input));
				
			
KEY:[Timeout] VAL:[100]; KEY:[User] VAL:['Admin']
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   // Capture the alphanumeric key and any literal value
   t.FromTo("{@Alpha:key} = {@Literal:val}", "KEY:[{key}] VAL:[{val}]");

   auto input = "Timeout = 100; User = 'Admin'";
   cout << t.Transform(input) << endl;
}
				
			
KEY:[Timeout] VAL:[100]; KEY:[User] VAL:['Admin']
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      '// Capture the alphanumeric key and any literal value
      t.FromTo("{@Alpha:key} = {@Literal:val}", "KEY:[{key}] VAL:[{val}]")
      
      Dim input = "Timeout = 100; User = 'Admin'"
      Console.WriteLine(t.Transform(input))
   End Sub
End Module
				
			
KEY:[Timeout] VAL:[100]; KEY:[User] VAL:['Admin']