Practical: Re-filters a result set to show only 'focusable' matches without re-running the search.

ID: 853

See: Reset
				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "ID:100, Name:Admin, ID:200";

// Define two rules, but only one is marked as 'focusable'
var idRule = t.Pattern("ID:{@Number}").SetFocusable(true);
var nameRule = t.Pattern("Name:{@Alpha}").SetFocusable(false);
t.Find();

var matches = t.GetMatches(MatchesOption.All);
Console.WriteLine("--- All Matches ---");
Console.WriteLine($"Count: {matches.Count()}");
Console.WriteLine(matches.Text);

// Now, re-filter the same results to get only the focusable ones
matches.Reset(MatchesOption.FocusableOnly);
Console.WriteLine("");
Console.WriteLine("--- Focusable Matches Only ---");
Console.WriteLine($"Count: {matches.Count()}");
Console.WriteLine(matches.Text);
				
			
--- All Matches ---
Count: 3
ID:100
Name:Admin
ID:200

--- Focusable Matches Only ---
Count: 2
ID:100
ID:200
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   t.Text("ID:100, Name:Admin, ID:200");

   // Define two rules, but only one is marked as 'focusable'
   auto idRule = t.Pattern("ID:{@Number}").SetFocusable(true);
   auto nameRule = t.Pattern("Name:{@Alpha}").SetFocusable(false);
   t.Find();

   auto matches = t.GetMatches(MatchesOption::All);
   cout << "--- All Matches ---" << endl;
   cout << "Count: " << matches.Count() << endl;
   cout << matches.Text() << endl;

   // Now, re-filter the same results to get only the focusable ones
   matches.Reset(MatchesOption::FocusableOnly);
   cout << "" << endl;
   cout << "--- Focusable Matches Only ---" << endl;
   cout << "Count: " << matches.Count() << endl;
   cout << matches.Text() << endl;
}
				
			
--- All Matches ---
Count: 3
ID:100
Name:Admin
ID:200

--- Focusable Matches Only ---
Count: 2
ID:100
ID:200
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      t.Text = "ID:100, Name:Admin, ID:200"
      
      '// Define two rules, but only one is marked as 'focusable'
      Dim idRule = t.Pattern("ID:{@Number}").SetFocusable(true)
      Dim nameRule = t.Pattern("Name:{@Alpha}").SetFocusable(false)
      t.Find()
      
      Dim matches = t.GetMatches(MatchesOption.All)
      Console.WriteLine("--- All Matches ---")
      Console.WriteLine($"Count: {matches.Count()}")
      Console.WriteLine(matches.Text)
      
      '// Now, re-filter the same results to get only the focusable ones
      matches.Reset(MatchesOption.FocusableOnly)
      Console.WriteLine("")
      Console.WriteLine("--- Focusable Matches Only ---")
      Console.WriteLine($"Count: {matches.Count()}")
      Console.WriteLine(matches.Text)
   End Sub
End Module
				
			
--- All Matches ---
Count: 3
ID:100
Name:Admin
ID:200

--- Focusable Matches Only ---
Count: 2
ID:100
ID:200