A practical example using a fallback content block to provide a default status for log entries.

ID: 791

				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();
// Pattern: Match "Log:", an optional level (Warning or Error), and the message.
// Replacement: Use `{!level:OK}` to insert 'OK' if no level was captured.
t.FromTo("Log: [{level: Warning | Error}] {msg}", "Status: {!level:OK}{level} | Message: {msg}");

Console.WriteLine(t.Transform("Log: This is a standard entry"));
Console.WriteLine(t.Transform("Log: Warning A potential issue was found"));
Console.WriteLine(t.Transform("Log: Error System failure detected"));
				
			
Status: OK | Message: This is a standard entry
Status: Warning | Message: A potential issue was found
Status: Error | Message: System failure detected
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;
   // Pattern: Match "Log:", an optional level (Warning or Error), and the message.
   // Replacement: Use `{!level:OK}` to insert 'OK' if no level was captured.
   t.FromTo("Log: [{level: Warning | Error}] {msg}", "Status: {!level:OK}{level} | Message: {msg}");

   cout << t.Transform("Log: This is a standard entry") << endl;
   cout << t.Transform("Log: Warning A potential issue was found") << endl;
   cout << t.Transform("Log: Error System failure detected") << endl;
}
				
			
Status: OK | Message: This is a standard entry
Status: Warning | Message: A potential issue was found
Status: Error | Message: System failure detected
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      '// Pattern: Match "Log:", an optional level (Warning or Error), and the message.
      '// Replacement: Use `{!level:OK}` to insert 'OK' if no level was captured.
      t.FromTo("Log: [{level: Warning | Error}] {msg}", "Status: {!level:OK}{level} | Message: {msg}")
      
      Console.WriteLine(t.Transform("Log: This is a standard entry"))
      Console.WriteLine(t.Transform("Log: Warning A potential issue was found"))
      Console.WriteLine(t.Transform("Log: Error System failure detected"))
   End Sub
End Module
				
			
Status: OK | Message: This is a standard entry
Status: Warning | Message: A potential issue was found
Status: Error | Message: System failure detected