mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-29 18:33:01 +00:00
Update split.lua
This commit is contained in:
parent
005615df02
commit
e24997dd80
1 changed files with 89 additions and 88 deletions
|
@ -58,11 +58,12 @@ end
|
||||||
|
|
||||||
--- Split a string into substrings separated by a pattern.
|
--- Split a string into substrings separated by a pattern.
|
||||||
-- @param str string The string to iterate over
|
-- @param str string The string to iterate over
|
||||||
-- @param dlm string The delimiter (separator) pattern
|
-- @param dlm string The delimiter (separator) pattern (default: "%s+")
|
||||||
-- @param plain boolean If true (or truthy), pattern is interpreted as a
|
-- @param plain boolean If true (or truthy), pattern is interpreted as a
|
||||||
-- plain string, not a Lua pattern
|
-- plain string, not a Lua pattern
|
||||||
-- @returns table A sequence table containing the substrings
|
-- @returns table A sequence table containing the substrings
|
||||||
local function split(str,dlm,plain)
|
local function split(str,dlm,plain)
|
||||||
|
if not dlm then dlm = "%s+" end
|
||||||
local pos, ret = 0, {}
|
local pos, ret = 0, {}
|
||||||
local ins, i = str:find(dlm,pos,plain)
|
local ins, i = str:find(dlm,pos,plain)
|
||||||
-- "if plain" shaves off some time in the while statement
|
-- "if plain" shaves off some time in the while statement
|
||||||
|
|
Loading…
Reference in a new issue