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.
Range
Method
Product:
Class:
Restricts all subsequent find and transform operations to a specific character range within the source text.
Syntax
Parameters
Return
Transformer
The current Transformer object, allowing for a fluent, chainable interface.
Remarks
(Note: This feature is not yet fully implemented and the final syntax may change.)
The Range method sets a "window" on the source text, restricting all subsequent find and transform operations to a specific sub-section of the string. This is a powerful performance optimization, as it avoids the memory allocation and copying overhead of creating a manual substring.
How It Works
When you call Range, the Transformer records the specified startPosition and length. Any subsequent calls to methods like Find() or Transform() will operate only within this virtual boundary.
Match positions (StartPosition, EndPosition) returned by the Matches object remain relative to the original, full source string, preserving their global coordinates.
To clear the range and revert to searching the entire string, you can call Range(0, -1).
💡 Why uCalc? (Comparative Analysis)
In a standard text processing workflow, to operate on a portion of a string, you must first create a substring.
Manual Substring Approach (Less Efficient):
// 1. Create a new string in memory.var sub = myString.Substring(100, 50);// 2. Perform the transformation on the new, smaller string.var result = t.Transform(sub);// 3. Manually stitch the result back into the original string.This approach is inefficient for large documents because it involves memory allocation and data copying. If you need the original match coordinates, you must also manually add the starting offset back.
The uCalc Range Advantage:uCalc's Range method is a zero-copy operation. It doesn't create a new string. Instead, it adjusts the transformer's internal pointers to define a virtual search area. This is significantly faster and uses less memory, making it the ideal solution for parsing specific sections of large files, such as the body of an HTTP response or the content within a specific XML/HTML tag.