2,342
edits
(Created page with "function string:split( inSplitPattern ) local outResults = {} local theStart = 1 local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )...") |
No edit summary |
||
Line 1: | Line 1: | ||
function | function mw.ustring:split( inSplitPattern ) | ||
local outResults = {} | local outResults = {} | ||
local theStart = 1 | local theStart = 1 | ||
local theSplitStart, theSplitEnd = | local theSplitStart, theSplitEnd = mw.ustring.find( self, inSplitPattern, theStart ) | ||
while theSplitStart do | while theSplitStart do | ||
table.insert( outResults, | table.insert( outResults, mw.ustring.sub( self, theStart, theSplitStart-1 ) ) | ||
theStart = theSplitEnd + 1 | theStart = theSplitEnd + 1 | ||
theSplitStart, theSplitEnd = | theSplitStart, theSplitEnd = mw.ustring.find( self, inSplitPattern, theStart ) | ||
end | end | ||
table.insert( outResults, | table.insert( outResults, mw.ustring.sub( self, theStart ) ) | ||
return outResults | return outResults | ||
end | end |