View Single Post
01-31-17, 04:57 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Lua contains string pattern matching functions that could easily strip out the UI escape tags shown.
Lua Code:
  1. local EscapePatterns={
  2.     "|[cC]%x%x%x%x%x%x";
  3.     "|T[^|]+|t";
  4.     "|H[^|]+|h%[(.-)%]|h";
  5. };
  6.  
  7. local function StripEscapes(str)
  8.     for _,pattern in ipairs(EscapePatterns) do
  9.         str=str:gsub(pattern,pattern:find("%(.-[^%%]%)") and "%1" or "");
  10.     end
  11.     return str:gsub("^%s*(.-)%s*$","%1"):gsub("%s+"," ");-- Strip extra spaces
  12. end
This is expandable so we can add more patterns later. Just put them in the EscapePatterns table.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote