Hi there,
I wonder if there is a faster... and better way to count a certain character in a string. In this case, I want to know how many times the "\" is in a string. I've solved it this way, but there should be a better way.... hopefully. Any suggestions? :-)
-- little trick to count depth of folders...
local _,_,weeknrcrap,crap = string.find(b,"Week%s+(%d+)\\(.*)")
local count = 0
while true do
if string.match(crap,"\\") then
s,e,crap = string.find(crap,"\\(.*)")
count = count+1
else
break
end
end
LogLine(hub,"debug",count.." times the '\\' in "..b)
OK... a new thought:
CountSlash = function(data)
local count = 0
for slash in string.gmatch(data, "\\")
count = count + 1
end
return count
end
This should be it.... I guess :P
Thank you Mutor 8)