Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim Document As String = "HEADER::BEGIN[data to find]END::FOOTER" '// 1. Isolate the content block we want to search in. '// Assume the block we care about is between BEGIN and END. Dim startIndex = document.IndexOf("BEGIN[") + 6 Dim endIndex = document.IndexOf("]END") Dim contentLength = endIndex - startIndex Dim contentBlock = document.Substring(startIndex, contentLength) Console.WriteLine($"Searching within substring: '{contentBlock}'") '// 2. Perform a find operation on just that substring. Dim t = uc.NewTransformer().SetText(contentBlock) t.Pattern("find") t.Find() Dim matches = t.Matches Console.WriteLine($"Local match StartPosition: {matches(0).StartPosition}") '// Relative to 'contentBlock' '// 3. Apply the offset to remap to the global 'document' coordinate space. matches.ApplyOffset(startIndex) Console.WriteLine($"Global match StartPosition: {matches(0).StartPosition}") End Sub End Module