I want to use split function of LUA 5.1 to split string of emoji characters without spaces and add space between ones, but I can't do it rightly. So I do it by this way, but it's wrong:
#!/usr/bin/env lua
local text = "๐๐ฝ๐๐ฝ๐ฅ๐๐น๐๐ฉโ๐ฉโ๐งโ๐ฆ๐จโ๐ฆโ๐ฆโโ"
for emoji in string.gmatch(text, "[%z\1-\127\194-\244][\128-\191]*") do
io.write(emoji .. " ")
end
See in browser Firefox 65!
MY WRONG RESULT: ๐ ๐ฝ ๐ ๐ฝ ๐ฅ ๐ ๐น ๐ ๐ฉ ๐ฉ ๐ง ๐ฆ ๐จ ๐ฆ ๐ฆ โ โ
WAITED RESULT: ๐๐ฝ ๐๐ฝ ๐ฅ ๐ ๐น ๐ ๐ฉโ๐ฉโ๐งโ๐ฆ ๐จโ๐ฆโ๐ฆ โ โ
local text = "๐๐ฝ๐๐ฝ๐ฅ๐๐น๐๐ฉโ๐ฉโ๐งโ๐ฆ๐จโ๐ฆโ๐ฆโโ"
for emoji in text
:gsub("(.)([\194-\244])", "%1\0%2")
:gsub("%z(\240\159\143[\187-\191])", "%1")
:gsub("%z(\239\184[\128-\143])", "%1")
:gsub("%z(\226\128\141)%z", "%1")
:gmatch"%Z+"
do
print(emoji)
end