all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
11
Task/Tokenize-a-string/Lua/tokenize-a-string-3.lua
Normal file
11
Task/Tokenize-a-string/Lua/tokenize-a-string-3.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
str = "Hello|How|Are|You||Today"
|
||||
|
||||
tokens = {}
|
||||
for w in string.gmatch( str, "([^|]*)|?" ) do
|
||||
tokens[#tokens+1] = w
|
||||
end
|
||||
table.remove(tokens)--pops off the last empty value, because without doing |? we lose the last element.
|
||||
|
||||
for i = 1, #tokens do
|
||||
print( tokens[i] )
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue