Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
18
Task/String-matching/Pluto/string-matching.pluto
Normal file
18
Task/String-matching/Pluto/string-matching.pluto
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
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)}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue