Actually, `grep --color=always` gives you exactly the information that would be needed for this. The matched characters would be surrounded by `\033[0;31m` and `\033[0m`. But relying on this would be hacky at best and could easily break with various grep implementations.