Skip to content

Instantly share code, notes, and snippets.

@yareally
Created July 8, 2016 00:30
Show Gist options
  • Save yareally/3ca09fb1773b68004f2bc261409fb392 to your computer and use it in GitHub Desktop.
Save yareally/3ca09fb1773b68004f2bc261409fb392 to your computer and use it in GitHub Desktop.
var haystack = "AABBCC";
var matches = rules.Where(kv => haystack.Contains(kv.Key)).ToDictionary(kv => kv.Key, kv => kv.Value);
var needle = matches.Any() ? matches.ElementAt(new Random().Next(matches.Count)).Key : "";
haystack.Replace(needle, rules[needle]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment