Module:SplitString

Revision as of 18:15, 9 August 2019 by Joseph.Wharfe (talk | contribs) (Created page with "function string:split( inSplitPattern ) local outResults = {} local theStart = 1 local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

function string:split( inSplitPattern )
 
    local outResults = {}
    local theStart = 1
    local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
 
    while theSplitStart do
        table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
        theStart = theSplitEnd + 1
        theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
    end
 
    table.insert( outResults, string.sub( self, theStart ) )
    return outResults
end