I'm trying to split a string by a single dot, yet retain double(and more) dots.
My approach is like this,which works only with double dots:
local s = "some string.. with several dots, added....more dots.another line inserted.";
for line in s:gsub('%.%.','#&'):gmatch('[^%.]+') do
print(line:gsub('#&','..'));
end
Another approach was like this
print(s:match('([^%.]+[%.]*[^%.]+)'))
which halts after the next sequence of dots, so it does not suit properly.
How could I accomplish this in a pattern matching?
local s = 'some string.. with several dots, added....more dots.another line inserted.'
for line in s:gsub("%f[.]%.%f[^.]", "\0"):gmatch"%Z+" do
print(line)
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With