I have text like this:

Code:
You see exits leading northeast, south, and northwest.


I need to detect all the ANSI codes (they all look like  or similar), and then return the whole phrase in mIRC codes (using the identifier $ansi2mirc). Where there is a different ANSI code, it needs to find the new color for when it changes, so there could be several different ANSI codes in a sentence, meaning that there would be several different colors. It has to find all of them. Thanks.

Note: Putting the whole thing, if there is more than once ANSI code, into $ansi2mirc returns an error, so that's not a possibility.