Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. public static string ReplaceTokens(string template, Dictionary<string, string> replacements)
  2. {
  3. var rex = new Regex(@":{([^}]+)}”);
  4. return(rex.Replace(template, delegate(Match m)
  5. {
  6. string key = m.Groups[1].Value;
  7. string rep = replacements.ContainsKey(key)? replacements[key] : m.Value;
  8. return(rep);
  9. }));
  10. }
  11.  
  12. var saida = ReplaceTokens(stringDoArquivo, dicionarioValores);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement