Iterates through matches, retrieves the rule for each, and uses ParentTransformer to get the transformer's description for context.

ID: 961

				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
t.Description = "My Main Transformer";
t.Text = "apple banana apple";

var appleRule = t.FromTo("apple", "APPLE");
var bananaRule = t.FromTo("banana", "BANANA");

t.Find();

foreach(var match in t.Matches) {
   var rule = match.Rule;
   var parent = rule.ParentTransformer;
   Console.WriteLine($"Match '{match.Text}' found by rule '{rule.Name}' in transformer '{parent.Description}'");
}
				
			
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer'
Match 'banana' found by rule 'banana' in transformer 'My Main Transformer'
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer'
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   t.Description("My Main Transformer");
   t.Text("apple banana apple");

   auto appleRule = t.FromTo("apple", "APPLE");
   auto bananaRule = t.FromTo("banana", "BANANA");

   t.Find();

   for(auto match : t.Matches()) {
      auto rule = match.Rule();
      auto parent = rule.ParentTransformer();
      cout << "Match '" << match.Text() << "' found by rule '" << rule.Name() << "' in transformer '" << parent.Description() << "'" << endl;
   }
}
				
			
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer'
Match 'banana' found by rule 'banana' in transformer 'My Main Transformer'
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer'
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      t.Description = "My Main Transformer"
      t.Text = "apple banana apple"
      
      Dim appleRule = t.FromTo("apple", "APPLE")
      Dim bananaRule = t.FromTo("banana", "BANANA")
      
      t.Find()
      
      For Each match In t.Matches
         Dim rule = match.Rule
         Dim parent = rule.ParentTransformer
         Console.WriteLine($"Match '{match.Text}' found by rule '{rule.Name}' in transformer '{parent.Description}'")
      Next
   End Sub
End Module
				
			
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer'
Match 'banana' found by rule 'banana' in transformer 'My Main Transformer'
Match 'apple' found by rule 'apple' in transformer 'My Main Transformer'