View Single Post
04/19/14, 09:05 PM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by gumphrey View Post
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:
  1. local textOut = string.gsub(textIn, "|H.-|h(.-)|h", "%1")
I'm not in game, so I did not try it.
  Reply With Quote