Parsing Key-Value pairs where values can be numbers or strings.
ID: 887
See: Introduction
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
// Use {@Literal} to match either numbers or strings
t.FromTo("{@Alpha:key} = {@Literal:val}", "Set {key} to {val}");
Console.WriteLine(t.Transform("Timeout = 100")); // Output: Set Timeout to 100
Console.WriteLine(t.Transform("Name = 'Admin'")); // Output: Set Name to 'Admin'
Set Timeout to 100
Set Name to 'Admin' using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); // Use {@Literal} to match either numbers or strings t.FromTo("{@Alpha:key} = {@Literal:val}", "Set {key} to {val}"); Console.WriteLine(t.Transform("Timeout = 100")); // Output: Set Timeout to 100 Console.WriteLine(t.Transform("Name = 'Admin'")); // Output: Set Name to 'Admin'
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
// Use {@Literal} to match either numbers or strings
t.FromTo("{@Alpha:key} = {@Literal:val}", "Set {key} to {val}");
cout << t.Transform("Timeout = 100") << endl; // Output: Set Timeout to 100
cout << t.Transform("Name = 'Admin'") << endl; // Output: Set Name to 'Admin'
}
Set Timeout to 100
Set Name to 'Admin' #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); // Use {@Literal} to match either numbers or strings t.FromTo("{@Alpha:key} = {@Literal:val}", "Set {key} to {val}"); cout << t.Transform("Timeout = 100") << endl; // Output: Set Timeout to 100 cout << t.Transform("Name = 'Admin'") << endl; // Output: Set Name to 'Admin' }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
'// Use {@Literal} to match either numbers or strings
t.FromTo("{@Alpha:key} = {@Literal:val}", "Set {key} to {val}")
Console.WriteLine(t.Transform("Timeout = 100")) '// Output: Set Timeout to 100
Console.WriteLine(t.Transform("Name = 'Admin'")) '// Output: Set Name to 'Admin'
End Sub
End Module
Set Timeout to 100
Set Name to 'Admin' Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() '// Use {@Literal} to match either numbers or strings t.FromTo("{@Alpha:key} = {@Literal:val}", "Set {key} to {val}") Console.WriteLine(t.Transform("Timeout = 100")) '// Output: Set Timeout to 100 Console.WriteLine(t.Transform("Name = 'Admin'")) '// Output: Set Name to 'Admin' End Sub End Module