How to split string in Lua by semicolon?
local destination_number="2233334;555555;12321315;2343242"
Here we can see that multiple times occurrence of semicolon (;) but I need output from above string only before first occurrence.
Tried code :
if string.match(destination_number, ";") then
for token in string.gmatch(destination_number, "([^;]+),%s*") do
custom_destination[i] = token
i = i + 1
end
end
Output :
2233334
I have tried above code but newbie to Lua scripting so can't get exact syntax for that.
destination_number:gmatch '(%d+);?'. Replace with%wif you need letters too. - greatwolf