Let me play with it. I wana try my idea. Can you help with something?
This is the string I have, "stonefalls/davonswatch_base"
Lua Code:
local count = 0
local mapParse = {}
for v1, v2 in string.gmatch (textureName, "(.-)%/") do
count = count +1
mapParse[count] = v1
d(count .. ") " .. v1)
d(count .. ") " .. mapParse[count])
end
I was looking through the lua.org stuff and could not find what I wanted. That crappy bit of code got me the first part of the string before the "/", "stonefalls" but not the second half. Then I tried your code and it's working. However, I have my doubts about my understanding of the syntax. I think I am doing it wrong and just getting lucky and they return what I want.
textureName = "stonefalls/davonswatch_base"
Lua Code:
local v1, v2 = select(3,textureName:find("([%w%-]+)/([%w%-]+_[%w%-]+)"))
I get "stonefalls" and "davonswatch_base" which is exactly what I want.
textureName = "stonefalls/davonswatch_base/davonswatch"
Lua Code:
local v1, v2, v3 = select(3,textureName:find("([%w%-]+)/([%w%-]+_[%w%-]+)/([%w%-]+)"))
I get "stonefalls", "davonswatch_base", and "davonswatch" which is exactly what I want.
textureName = "stonefalls/stonefalls_base"
Lua Code:
local v1, v2, v3 = select(3,textureName:find("([%w%-]+)/([%w%-]+)_([%w%-]+)"))
I get "stonefalls", "stonefalls", and "base" which is exactly what I want.
Q1) Did I do it right?
Q2) Why does 3 work in all cases. I tried a 2 for the first example with only v1, and v2 and I got a number and a string.