28 posts
Location
<Insert a location joke here>
Posted 23 June 2015 - 06:17 PM
I want to split strings , but not with the default paterns like this:
for token in gmatch("lalla", [^%p]+) do
or with %a %c %d %l %w etc…
i want to do that but with a designated patern like this:
(not a real code , you know)
for token in gmatch("la:la\la.la", "\")
then the results will be : la:la and la.la
(sorry for any English error)
2679 posts
Location
You will never find me, muhahahahahaha
Posted 23 June 2015 - 06:26 PM
What exactly do you mean?
28 posts
Location
<Insert a location joke here>
Posted 23 June 2015 - 06:32 PM
anything like split string with my , i choice , the term of the separation.
without use a patern like separete with ponctuation by %p
2679 posts
Location
You will never find me, muhahahahahaha
Posted 23 June 2015 - 06:34 PM
ok, here it goes:
local function split(str,sep)
sep = sep or " "
local ret = {}
for token in str:gmatch("[^"..sep.."]+") do
ret[#ret+1] = token
end
return ret end
Edited on 23 June 2015 - 04:35 PM
28 posts
Location
<Insert a location joke here>
Posted 23 June 2015 - 06:41 PM
so with this the result will come in a table?
I need to use the table or i can make with other thing?
28 posts
Location
<Insert a location joke here>
Posted 23 June 2015 - 06:57 PM
ok , it works , thanks
2679 posts
Location
You will never find me, muhahahahahaha
Posted 23 June 2015 - 07:19 PM
ok , it works , thanks
You are welcome!