гм, ось, що в мене вийшло:
local lpos
local found -- for some reason lpos is not preserved on break's
for lpos=1,#compl[1] do
local str
for _, str in pairs(compl) do
if str:sub(lpos,lpos) ~= compl[1]:sub(lpos,lpos) then
found = lpos - 1
break
end
end
if found then
break
end
end
if not found then
found = #comp[1] - 1
end