Module:Util/strings/startsWith

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search

startsWith(str, substr)

Returns

  • true if str starts with substr, else false.

Examples

#InputOutputResult
1
startsWith("Fooloo Limpah", "Foo")
true
2
startsWith("Fooloo Limpah", "foo")
false
3
startsWith("Fooloo Limpah", "")
true
4
startsWith("[[foo]]", "[[")
true

local function startsWith(str, substr)
	return substr == string.sub(str, 1, #substr)
end

return startsWith