Random Macro Function
This will take an input string with words inside brackets and replace them with a random word from the list.
using System;
using System.Text.RegularExpressions;
namespace RandomMacroExample
{
class Program
{
static Random random = new Random((int)DateTime.Now.Ticks);
static string RandomMacro(string input)
{
Regex rx = new Regex(@"{(.*?)}");
string result = rx.Replace(input, new MatchEvaluator((Match m) =>
{
string[] x = m.Groups[1].ToString().Split(new char[] { '|' });
return x[random.Next(0, x.Length)];
}));
return result;
}
static void Main(string[] args)
{
Console.WriteLine(RandomMacro("This stuff is totally {cool|lame|stupid|awesome}. Lets go to the {mall|skate shop|gas station}"));
Console.WriteLine(RandomMacro("This stuff is totally {cool|lame|stupid|awesome}. Lets go to the {mall|skate shop|gas station}"));
Console.WriteLine(RandomMacro("This stuff is totally {cool|lame|stupid|awesome}. Lets go to the {mall|skate shop|gas station}"));
Console.WriteLine(RandomMacro("This stuff is totally {cool|lame|stupid|awesome}. Lets go to the {mall|skate shop|gas station}"));
Console.WriteLine(RandomMacro("This stuff is totally {cool|lame|stupid|awesome}. Lets go to the {mall|skate shop|gas station}"));
Console.ReadLine();
}
}
}

