Jump to content

Tokenize a string: Difference between revisions

Removed my recent surplus contribution
(→‎{{header|Lua}}: Changed to use in-built table.concat function)
(Removed my recent surplus contribution)
Line 960:
Reconstitutes to "Hello.How.Are.You.Today"
</pre>
 
=={{header|Lua}}==
Split function callously stolen from the lua-users wiki
<lang Lua>function string:split (sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
 
local str = "Hello,How,Are,You,Today"
print(table.concat(str:split(","), "."))</lang>
{{out}}
<pre>Hello.How.Are.You.Today</pre>
 
=={{header|K}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.