Originally Posted by merlight
I find your replacement code quite convoluted Try this:
Lua Code:
link:gsub("|H(%x%x%x%x%x%x)(.-|h)(.-)|h", "|H0%2|h") -- first capture matches six hex digits, which are discarded -- second capture matches everything up to and including |h, and is put in replacement %2 -- third capture matches everything up to second |h (link text, discarded) -- you can use it on old and new links alike, no need to test which format you have -- on new links it wil just not replace anything, because the |Hxcolor code won't match
edit: oops, somehow I dropped one x from the pattern. fixed
|
Thanks, this information is appreciated. I know about the gsub routines but I have revised my code somewhat to be less repetitive but this way I know when I look at the code in 6 months time I won't have to research how gsub works again rofl. And seeing as this should be one of those one off conversion things it won't be used much.
Lua Code:
if (linkData[2] ~= "0" and linkData[2] ~= "1") or linkData[2] == "0" then
local newLink = "|H1"
for i = 3, 23 do
newLink = newLink..":"..linkData[i]
end
newLink = newLink.."|h|h"
itemLink = newLink
end