Tokenize a string: Difference between revisions

Content added Content deleted
(→‎{{header|Lua}}: Changed to use in-built table.concat function)
(Removed my recent surplus contribution)
Line 960: Line 960:
Reconstitutes to "Hello.How.Are.You.Today"
Reconstitutes to "Hello.How.Are.You.Today"
</pre>
</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}}==
=={{header|K}}==