Internal Test: Uses integer tags to programmatically categorize matches and process them differently in a loop.
ID: 828
See: Rule = [Rule]
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
t.Text = "Log: INFO message. Log: ERROR alert. Log: INFO another message.";
var infoRule = t.Pattern("Log: INFO {msg}.").SetTag(1); // Tag 1 for INFO
var errorRule = t.Pattern("Log: ERROR {msg}.").SetTag(99); // Tag 99 for ERROR
t.Find();
foreach(var match in t.Matches) {
var ruleTag = match.Rule.Tag;
if (ruleTag == 1) {
Console.WriteLine($"Found informational log: {match.Text}");
}
if (ruleTag == 99) {
Console.WriteLine($"!!! Found CRITICAL error: {match.Text} !!!");
}
}
Found informational log: Log: INFO message.
!!! Found CRITICAL error: Log: ERROR alert. !!!
Found informational log: Log: INFO another message. using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); t.Text = "Log: INFO message. Log: ERROR alert. Log: INFO another message."; var infoRule = t.Pattern("Log: INFO {msg}.").SetTag(1); // Tag 1 for INFO var errorRule = t.Pattern("Log: ERROR {msg}.").SetTag(99); // Tag 99 for ERROR t.Find(); foreach(var match in t.Matches) { var ruleTag = match.Rule.Tag; if (ruleTag == 1) { Console.WriteLine($"Found informational log: {match.Text}"); } if (ruleTag == 99) { Console.WriteLine($"!!! Found CRITICAL error: {match.Text} !!!"); } }
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
t.Text("Log: INFO message. Log: ERROR alert. Log: INFO another message.");
auto infoRule = t.Pattern("Log: INFO {msg}.").SetTag(1); // Tag 1 for INFO
auto errorRule = t.Pattern("Log: ERROR {msg}.").SetTag(99); // Tag 99 for ERROR
t.Find();
for(auto match : t.Matches()) {
auto ruleTag = match.Rule().Tag();
if (ruleTag == 1) {
cout << "Found informational log: " << match.Text() << endl;
}
if (ruleTag == 99) {
cout << "!!! Found CRITICAL error: " << match.Text() << " !!!" << endl;
}
}
}
Found informational log: Log: INFO message.
!!! Found CRITICAL error: Log: ERROR alert. !!!
Found informational log: Log: INFO another message. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; t.Text("Log: INFO message. Log: ERROR alert. Log: INFO another message."); auto infoRule = t.Pattern("Log: INFO {msg}.").SetTag(1); // Tag 1 for INFO auto errorRule = t.Pattern("Log: ERROR {msg}.").SetTag(99); // Tag 99 for ERROR t.Find(); for(auto match : t.Matches()) { auto ruleTag = match.Rule().Tag(); if (ruleTag == 1) { cout << "Found informational log: " << match.Text() << endl; } if (ruleTag == 99) { cout << "!!! Found CRITICAL error: " << match.Text() << " !!!" << endl; } } }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
t.Text = "Log: INFO message. Log: ERROR alert. Log: INFO another message."
Dim infoRule = t.Pattern("Log: INFO {msg}.").SetTag(1) '// Tag 1 for INFO
Dim errorRule = t.Pattern("Log: ERROR {msg}.").SetTag(99) '// Tag 99 for ERROR
t.Find()
For Each match In t.Matches
Dim ruleTag = match.Rule.Tag
If ruleTag = 1 Then
Console.WriteLine($"Found informational log: {match.Text}")
End If
If ruleTag = 99 Then
Console.WriteLine($"!!! Found CRITICAL error: {match.Text} !!!")
End If
Next
End Sub
End Module
Found informational log: Log: INFO message.
!!! Found CRITICAL error: Log: ERROR alert. !!!
Found informational log: Log: INFO another message. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() t.Text = "Log: INFO message. Log: ERROR alert. Log: INFO another message." Dim infoRule = t.Pattern("Log: INFO {msg}.").SetTag(1) '// Tag 1 for INFO Dim errorRule = t.Pattern("Log: ERROR {msg}.").SetTag(99) '// Tag 99 for ERROR t.Find() For Each match In t.Matches Dim ruleTag = match.Rule.Tag If ruleTag = 1 Then Console.WriteLine($"Found informational log: {match.Text}") End If If ruleTag = 99 Then Console.WriteLine($"!!! Found CRITICAL error: {match.Text} !!!") End If Next End Sub End Module