Stripping text color from GameTooltip

Heya,

When using GameTooltipTextLeft:GetText() the string it returns seems to keep its color formatting, is there anyway to strip any colors from the returned string?

For example the minimap tracking, if the entity you’re tracking is inside a building it’s given a grey color.

To see this, use this macro while hovering your mouse over a tracked target.
/run for i=1,GameTooltip:NumLines()do local mytext=_G[“GameTooltipTextLeft”…i] local text=mytext:GetText() print(text)end

Anyone know how to do this?

Problem is if you try to use that text anywhere else, like in SendChatMessage for example, the game will throw you invalid escape character errors as it tries to read the color formatting.

i have this function to strip out the colour codes.

its just a gsub to replace the code text with an empty string

function ArkInventory.StripColourCodes( txt )
	local txt = txt or ""
	txt = string.gsub( txt, "|c%x%x%x%x%x%x%x%x", "" )
	txt = string.gsub( txt, "|c%x%x %x%x%x%x%x", "" ) -- the trading parts colour has a space instead of a zero for some weird reason
	txt = string.gsub( txt, "|r", "" )
	return txt
end