Reference › Function reference › Functions

Functions.text.starts_with

public

Call as

Functions.text.starts_with(str, start)

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

What it does

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

Arguments

NameTypeWhat it does
strstringText to inspect.
startstringLiteral prefix, including an empty prefix.

Returns

1booleanWhether the text begins with the exact prefix.

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 zone = GetRealZoneText() or ""
return Functions.text.starts_with(zone, "Molten")

Source

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

Functions.text.starts_with(str, start)
    return str:sub(1, #start) == start

Back to Function reference