I'm doing a parser for build outputs, and I'd like to highlight different patterns in different colors. So for example, I'd like to do:
sed -e "s|\(Error=errcode1\)|<red>\1<_red>|" \ -e "s|\(Error=errcode2\)|<orange>\1<_orange>|" \ -e "s|\(Error=.*\)|<blue>\1<_blue>|" (so it higlights errcode1 in red, errcode2 in orange, and anything else in blue). The problem with this is that Error=errcode1 matches both the first and the third expression, which will result in <red><blue>Error=errcode1<_red><_blue>... Is there any way to tell sed to match only the first expression, and if it does, do not try the following expressions?
Note, the sed command will actually be auto-generated from files which will be very volatile, so I'd like a generic solution where I don't have to police whether patterns conflict...