Making many assumptions about your environment (eg, this may not work, but it works sometimes), you can make every line that matches the string "foo" red with:
$ RED=$(printf '\033[01;31m')
$ GREEN=$(printf '\033[01;32m')
$ printf 'foo\nbar\n' | sed "/foo/{s/^/$RED/; s/\$/$GREEN/}"
Replace foo
in the pattern match with a pattern you want to match, and sed will emit the color codes at the beginning and ending of the line to change the presentation. In this example, I change the color back to green. It is difficult to attempt to restore the color to its previous state, and much simpler to choose a color rather than trying to do so. You can choose a different color code to match your preferred output.