fork(19) download
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var variablesDictionary = new Dictionary<string, string>();
  11. variablesDictionary.Add("$$@Key", "Value");
  12. var pattern = @"\$\$@[a-zA-Z0-9_]+\b";
  13. var stringVariableMatches = Regex.Replace("$$@Unknown and $$@Key", pattern,
  14. m => variablesDictionary.ContainsKey(m.Value) ? variablesDictionary[m.Value] : m.Value);
  15. Console.WriteLine(stringVariableMatches);
  16. }
  17.  
  18.  
  19. }
  20.  
  21.  
Success #stdin #stdout 0.03s 134208KB
stdin
Standard input is empty
stdout
$$@Unknown and Value