Originally Posted by gumphrey
I am trying to get plain text out of chat messages. I want to strip all the color codes, link information, etc. just leaving a plain text version of the message. Is there an existing method exposed that can do that?
I have been experimenting with using string.gsub to remove the text, but it doesn't work except for very simple patterns. For instance, in stand alone lua I can use this pattern to find item links and replace them with just plain text in square brackets. In my addon, it does nothing...
local textOut = string.gsub(textIn, 'H.-h(%[.-%])h', '%1')
|
Item link starts with "|H" then it contains clolor code, link type etc and ends with "|h" then there is item name (or just text to disply) and "|h" again. If I'm not mistaken, there are no [] in item name, so you should change pattern.
lua Code:
local textOut = string.gsub(textIn, "|H.-|h(.-)|h", "%1")
I'm not in game, so I did not try it.