Module:SplitString: Difference between revisions

no edit summary
(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 string:split( inSplitPattern )
function mw.ustring:split( inSplitPattern )
   
   
     local outResults = {}
     local outResults = {}
     local theStart = 1
     local theStart = 1
     local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
     local theSplitStart, theSplitEnd = mw.ustring.find( self, inSplitPattern, theStart )
   
   
     while theSplitStart do
     while theSplitStart do
         table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
         table.insert( outResults, mw.ustring.sub( self, theStart, theSplitStart-1 ) )
         theStart = theSplitEnd + 1
         theStart = theSplitEnd + 1
         theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
         theSplitStart, theSplitEnd = mw.ustring.find( self, inSplitPattern, theStart )
     end
     end
   
   
     table.insert( outResults, string.sub( self, theStart ) )
     table.insert( outResults, mw.ustring.sub( self, theStart ) )
     return outResults
     return outResults
end
end