using System;
using System.Text.RegularExpressions;
namespace Refs
{
// Refs shared class.
class RefsShared
{
// Highlight output according to a regular expression.
public static void Highlight(String Output, Regex Pattern, ConsoleColor Colour)
{
// Create an array of "slices" of Output, "cut" by Pattern.
String[] OutputSlices = Pattern.Replace(Output, "*").Split('*');
// Loop through all the slices.
for (int Count = 0; Count < OutputSlices.Length; Count++)
{
Console.Write(OutputSlices[Count]);
MatchCollection Matches = Pattern.Matches(Output);
// Only between arrays should the match be written.
if (Count != (OutputSlices.Length - 1))
{
Console.ForegroundColor = Colour;
Console.Write(Matches[Count].Value);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
}
}
}