Reference › Function reference › Functions

Functions.text.ends_with

public

Call as

Functions.text.ends_with(str, ending)

Record it as a dependency named Functions.text.ends_with (accepting the completion does this), then call it by that name.

What it does

Test a literal byte suffix using a Lua string slice. Empty suffixes match; pattern characters have no special meaning and case is preserved.

Arguments

NameTypeWhat it does
strstringText to inspect.
endingstringLiteral suffix, including an empty suffix.

Returns

1booleanWhether the text ends with the exact suffix.

Editions

Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.

It reads no game API directly.

Example

local name = UnitName("target") or ""
return Functions.text.ends_with(name, "Totem")

Source

Functions/text.lua, line 70. Read only in game; Duplicate makes an editable copy.

Functions.text.ends_with(str, ending)
    return ending == "" or str:sub(-#ending) == ending

Back to Function reference