fork 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("$$@Unknown", "11111111111111111111");
  12. variablesDictionary.Add("$$@Key", "Value");
  13. var pattern = @"\$\$@[a-zA-Z0-9_]+\b";
  14. var stringVariableMatches = Regex.Replace("$$@Unknown and $$@Key", pattern,
  15. m => {
  16. Console.WriteLine(m.Index);
  17. Console.WriteLine(m.Length);
  18. return variablesDictionary.ContainsKey(m.Value) ? variablesDictionary[m.Value] : m.Value;
  19. });
  20. Console.WriteLine(stringVariableMatches);
  21. }
  22.  
  23.  
  24. }
  25.  
  26.  
Success #stdin #stdout 0.11s 29240KB
stdin
Standard input is empty
stdout
0
10
15
6
11111111111111111111 and Value