-
StackOverflow 文档
-
Lua 教程
-
编写和使用模块
-
使用该模块
-- The following assumes that trim module is installed or in the caller's package.path,
-- which is a built-in variable that Lua uses to determine where to look for modules.
local trim = require "trim"
local msg = " Hello, world! "
local cleaned = trim.trim_all(msg)
local cleaned_right = trim.trim_right(msg)
local cleaned_left = trim.trim_left(msg)
-- It's also easy to alias functions to shorter names.
local trimr = trim.trim_right
local triml = trim.trim_left