Module:Util/strings/endsWith: Difference between revisions

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search
(Created page with "local function endsWith() end return endsWith")
 
No edit summary
 
Line 1: Line 1:
local function endsWith()
local function endsWith(str, substr)
return substr == string.sub(str, #str - #substr + 1, #str)
end
end


return endsWith
return endsWith

Latest revision as of 21:08, 5 May 2024

endsWith(str, substr)

Returns

  • true if str ends with substr, else false.

Examples

#InputOutputResult
1
endsWith("Fooloo Limpah", "Limpah")
true
Green check.svg
2
endsWith("Fooloo Limpah", "limpah")
false
Green check.svg
3
endsWith("Fooloo Limpah", "")
true
Green check.svg
4
endsWith("Wood (Character)", ")", true)
true
Green check.svg

local function endsWith(str, substr)
	return substr == string.sub(str, #str - #substr + 1, #str)
end

return endsWith