This is a technical issue, but as an exercise, I intend to write a PS to accept the input with channels, with a regular expression as a parameter, and select any text that matches the regular expression.
The part I cannot find information for is that it easily matches text, captures a buffer, or replaces text. But I need to replace the corresponding text with the color, the original text, and then resume the previous color. It seems I cannot find any way to generate an output color other than write-output, and cannot make separate colors in one record, which would mean:
regular regular expression
-write-host print all text before the default color match, using -NoNewLine
-write-host match, with -NoNewLine
-write-host remainder
It seems dirty and gets even more dirty if we want to maintain multiple matches. Is there a more eloquent way to do this?
Kevin source share