justync7

split

Jul 19th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. function string:split( inSplitPattern, outResults )
  2.  
  3. if not outResults then
  4. outResults = { }
  5. end
  6. local theStart = 1
  7. local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
  8. while theSplitStart do
  9. table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
  10. theStart = theSplitEnd + 1
  11. theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
  12. end
  13. table.insert( outResults, string.sub( self, theStart ) )
  14. return outResults
  15. end
Add Comment
Please, Sign In to add comment