A practical example using `MatchesOption::FocusableOnly` to retrieve results only from rules marked as focusable.
ID: 877
See: GetMatches
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "ID:100, Name:Admin, ID:200";
// Mark 'ID' rules as focusable, but 'Name' rules as secondary.
var idRule = t.Pattern("ID:{@Number}").SetFocusable(true);
var nameRule = t.Pattern("Name:{@Alpha}").SetFocusable(false);
t.Find();
// Get the matches for the 'idRule' specifically, filtered to only focusable results.
var focusableIdMatches = idRule.GetMatches(MatchesOption.FocusableOnly);
Console.WriteLine($"Focusable 'ID' matches found: {focusableIdMatches.Count()}");
Console.WriteLine(focusableIdMatches.Text);
Focusable 'ID' matches found: 2
ID:100
ID:200 using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Text = "ID:100, Name:Admin, ID:200"; // Mark 'ID' rules as focusable, but 'Name' rules as secondary. var idRule = t.Pattern("ID:{@Number}").SetFocusable(true); var nameRule = t.Pattern("Name:{@Alpha}").SetFocusable(false); t.Find(); // Get the matches for the 'idRule' specifically, filtered to only focusable results. var focusableIdMatches = idRule.GetMatches(MatchesOption.FocusableOnly); Console.WriteLine($"Focusable 'ID' matches found: {focusableIdMatches.Count()}"); Console.WriteLine(focusableIdMatches.Text);
#include
#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");
// Mark 'ID' rules as focusable, but 'Name' rules as secondary.
auto idRule = t.Pattern("ID:{@Number}").SetFocusable(true);
auto nameRule = t.Pattern("Name:{@Alpha}").SetFocusable(false);
t.Find();
// Get the matches for the 'idRule' specifically, filtered to only focusable results.
auto focusableIdMatches = idRule.GetMatches(MatchesOption::FocusableOnly);
cout << "Focusable 'ID' matches found: " << focusableIdMatches.Count() << endl;
cout << focusableIdMatches.Text() << endl;
}
Focusable 'ID' matches found: 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"); // Mark 'ID' rules as focusable, but 'Name' rules as secondary. auto idRule = t.Pattern("ID:{@Number}").SetFocusable(true); auto nameRule = t.Pattern("Name:{@Alpha}").SetFocusable(false); t.Find(); // Get the matches for the 'idRule' specifically, filtered to only focusable results. auto focusableIdMatches = idRule.GetMatches(MatchesOption::FocusableOnly); cout << "Focusable 'ID' matches found: " << focusableIdMatches.Count() << endl; cout << focusableIdMatches.Text() << endl; }
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"
'// Mark 'ID' rules as focusable, but 'Name' rules as secondary.
Dim idRule = t.Pattern("ID:{@Number}").SetFocusable(true)
Dim nameRule = t.Pattern("Name:{@Alpha}").SetFocusable(false)
t.Find()
'// Get the matches for the 'idRule' specifically, filtered to only focusable results.
Dim focusableIdMatches = idRule.GetMatches(MatchesOption.FocusableOnly)
Console.WriteLine($"Focusable 'ID' matches found: {focusableIdMatches.Count()}")
Console.WriteLine(focusableIdMatches.Text)
End Sub
End Module
Focusable 'ID' matches found: 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" '// Mark 'ID' rules as focusable, but 'Name' rules as secondary. Dim idRule = t.Pattern("ID:{@Number}").SetFocusable(true) Dim nameRule = t.Pattern("Name:{@Alpha}").SetFocusable(false) t.Find() '// Get the matches for the 'idRule' specifically, filtered to only focusable results. Dim focusableIdMatches = idRule.GetMatches(MatchesOption.FocusableOnly) Console.WriteLine($"Focusable 'ID' matches found: {focusableIdMatches.Count()}") Console.WriteLine(focusableIdMatches.Text) End Sub End Module