Call as
Functions.text.trim(s)
Record it as a dependency named Functions.text.trim (accepting the completion does this), then call it by that name.
Also accepted under the former namespace utils.
What it does
Remove leading and trailing Lua-pattern whitespace from a string.
Arguments
| Name | Type | What it does |
|---|---|---|
s | string | Text to trim. |
Returns
| 1 | string | Trimmed text. |
|---|
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 = Functions.text.trim(GetUnitName("target", false) or "")
return name ~= ""Source
Functions/text.lua, line 54. Read only in game; Duplicate makes an editable copy.
Functions.text.trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))