local s = "abracadabra" local t = "abra" local u = "ra" local v = "cad" print($"'{s}' starts with '{t}' is {s:startswith(t)}") local indices = {} local start = 1 while true do local ix = s:find(u, start, true) if ix then indices:insert(ix) start = ix + #u if start > #s then break end else break end end local contained = #indices > 0 print($"'{s}' contains '{u}' is {contained} {contained ? $"at indices {indices:concat(", ")}" : ""}") print($"'{s}' ends with '{v}' is {s:endswith(v)}")