mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-24 16:46:04 +00:00
api: return when no subject was given to strsplit
This commit is contained in:
@@ -14,6 +14,7 @@ mod = math.mod or mod
|
||||
-- 'subject' [string] String to split.
|
||||
-- return: [list] a list of strings.
|
||||
function pfUI.api.strsplit(delimiter, subject)
|
||||
if not subject then return nil end
|
||||
local delimiter, fields = delimiter or ":", {}
|
||||
local pattern = string.format("([^%s]+)", delimiter)
|
||||
string.gsub(subject, pattern, function(c) fields[table.getn(fields)+1] = c end)
|
||||
|
||||
Reference in New Issue
Block a user