(Real World: Currency Formatter) Finding raw numbers in a text stream and converting them to a formatted currency string.
ID: 251
See: {@Number}, Introduction
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("Price: {@Number:amt}", "Price: ${amt}");
string input = "Item A Price: 19.99, Item B Price: 5";
Console.WriteLine(t.Transform(input));
Item A Price: $19.99, Item B Price: $5 using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("Price: {@Number:amt}", "Price: ${amt}"); string input = "Item A Price: 19.99, Item B Price: 5"; Console.WriteLine(t.Transform(input));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("Price: {@Number:amt}", "Price: ${amt}");
string input = "Item A Price: 19.99, Item B Price: 5";
cout << t.Transform(input) << endl;
}
Item A Price: $19.99, Item B Price: $5 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("Price: {@Number:amt}", "Price: ${amt}"); string input = "Item A Price: 19.99, Item B Price: 5"; cout << t.Transform(input) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("Price: {@Number:amt}", "Price: ${amt}")
Dim input As String = "Item A Price: 19.99, Item B Price: 5"
Console.WriteLine(t.Transform(input))
End Sub
End Module
Item A Price: $19.99, Item B Price: $5 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("Price: {@Number:amt}", "Price: ${amt}") Dim input As String = "Item A Price: 19.99, Item B Price: 5" Console.WriteLine(t.Transform(input)) End Sub End Module