fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var s = "(Price+Discounted_Price)*2-Max.Price";
  9. var dct = new Dictionary<string, string>();
  10. dct.Add("Price", "A1");
  11. dct.Add("Discounted_Price", "A2");
  12. dct.Add("Max.Price","A3");
  13. var res = Regex.Replace(s, @"(?<![\w.])[\w.]+(?![\w.])",
  14. x => dct.ContainsKey(x.Value) ? dct[x.Value] : x.Value);
  15. Console.WriteLine(res);
  16. }
  17. }
Success #stdin #stdout 0.1s 24576KB
stdin
Standard input is empty
stdout
(A1+A2)*2-A3