A practical debugging example that identifies which pattern string generated each match.
ID: 964
See: Pattern = [string]
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Text = "An apple and a car.";
// Define two separate rules
t.FromTo("apple", "[FRUIT]");
t.FromTo("car", "[VEHICLE]");
t.Find();
var matches = t.Matches;
Console.WriteLine($"Found {matches.Count()} matches:");
foreach(var match in matches) {
var rule = match.Rule;
Console.WriteLine($"- Matched '{match.Text}' using pattern: '{rule.Pattern}'");
}
Found 2 matches:
- Matched 'apple' using pattern: 'apple'
- Matched 'car' using pattern: 'car' using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Text = "An apple and a car."; // Define two separate rules t.FromTo("apple", "[FRUIT]"); t.FromTo("car", "[VEHICLE]"); t.Find(); var matches = t.Matches; Console.WriteLine($"Found {matches.Count()} matches:"); foreach(var match in matches) { var rule = match.Rule; Console.WriteLine($"- Matched '{match.Text}' using pattern: '{rule.Pattern}'"); }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.Text("An apple and a car.");
// Define two separate rules
t.FromTo("apple", "[FRUIT]");
t.FromTo("car", "[VEHICLE]");
t.Find();
auto matches = t.Matches();
cout << "Found " << matches.Count() << " matches:" << endl;
for(auto match : matches) {
auto rule = match.Rule();
cout << "- Matched '" << match.Text() << "' using pattern: '" << rule.Pattern() << "'" << endl;
}
}
Found 2 matches:
- Matched 'apple' using pattern: 'apple'
- Matched 'car' using pattern: 'car' #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.Text("An apple and a car."); // Define two separate rules t.FromTo("apple", "[FRUIT]"); t.FromTo("car", "[VEHICLE]"); t.Find(); auto matches = t.Matches(); cout << "Found " << matches.Count() << " matches:" << endl; for(auto match : matches) { auto rule = match.Rule(); cout << "- Matched '" << match.Text() << "' using pattern: '" << rule.Pattern() << "'" << endl; } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.Text = "An apple and a car."
'// Define two separate rules
t.FromTo("apple", "[FRUIT]")
t.FromTo("car", "[VEHICLE]")
t.Find()
Dim matches = t.Matches
Console.WriteLine($"Found {matches.Count()} matches:")
For Each match In matches
Dim rule = match.Rule
Console.WriteLine($"- Matched '{match.Text}' using pattern: '{rule.Pattern}'")
Next
End Sub
End Module
Found 2 matches:
- Matched 'apple' using pattern: 'apple'
- Matched 'car' using pattern: 'car' Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.Text = "An apple and a car." '// Define two separate rules t.FromTo("apple", "[FRUIT]") t.FromTo("car", "[VEHICLE]") t.Find() Dim matches = t.Matches Console.WriteLine($"Found {matches.Count()} matches:") For Each match In matches Dim rule = match.Rule Console.WriteLine($"- Matched '{match.Text}' using pattern: '{rule.Pattern}'") Next End Sub End Module