Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      Dim log = "INFO: Task started. ERROR: Connection failed. INFO: Task finished."
      
      
      Dim infoRule = t.Pattern("INFO: {msg}.")
      Dim errorRule = t.Pattern("ERROR: {msg}.")
      t.Text = log
      t.Find()
      
      '// Get the first match specific to the error rule
      Dim firstErrorMatch = errorRule.Matches(0)
      Console.WriteLine($"First error match text: '{firstErrorMatch.Text}'")
      
      '// Now, find its index within the global list of all matches
      Dim globalIndex = t.Matches.IndexOf(firstErrorMatch.StartPosition)
      Console.WriteLine($"The first error is the match at global index: {globalIndex}")
      
      '// Verify by printing the match from the global list
      Console.WriteLine($"Global match at that index: '{t.Matches(globalIndex).Text}'")
   End Sub
End Module