using uCalcSoftware; var uc = new uCalc(); string document = "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. var startIndex = document.IndexOf("BEGIN[") + 6; var endIndex = document.IndexOf("]END"); var contentLength = endIndex - startIndex; var contentBlock = document.Substring(startIndex, contentLength); Console.WriteLine($"Searching within substring: '{contentBlock}'"); // 2. Perform a find operation on just that substring. var t = uc.NewTransformer().SetText(contentBlock); t.Pattern("find"); t.Find(); var 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}");