Regex is definitely an opportunity, although whether it is βfasterβ or more readable, depends on personal preferences and your ability to read regular expressions. If the actual use case for this really just reads these two colors, rather than an arbitrary number of colors, then I will probably just stay with the original solution. The goal is perfectly clear, keeping the code simple and avoiding subtle mistakes if Regexes are not your forte.
LINQ is probably the most readable option and easily reads a few key-value pairs, while still using a simple separation mechanism for data analysis.
From my experience, what you should definitely avoid for the sake of convenience is to write a very complex, general, and seemingly βneatβ solution to the problem, it is small and simple.
source share