I am writing an external AddOn that converts invalid itemID lists into valid ones for TradeSkillMaster. However, for all that I have been reading on wowpedia.org and the official Lua documentation, I am stuck on matching exactly what I want in strings.
These are valid for TSM:
While these are not valid:
TSM requires itemIDs in the format "i:12345" and comma seperated if there are more than one. Okay, great. I can use string.gmatch (I don't care about what position the numbers are, so I'm not using string.match) like so:
local maybe_valid = string.gmatch(myString, "%d+$"
But that will match both examples above, valid and not valid. That won't work. How do I force the match to start at the first character of the string?
Checking if it is valid is easy, I think.
local valid = string.gmatch(myString, "i:%d+$"
The reason for knowing the difference is that after finding invalid strings, I will use string.gsub(myString, ",", ",i:") to fix them. Clearly I don't want to fix a string that is already valid.
Last edited by myrroddin : 01-12-19 at 11:47 AM.
Reason: next step