Jump to content

Split


Karoffe

Recommended Posts

I know how to use the split function, but I really need to understand how can it be done manually,

so lets imagine that this function doesn't even exist how can I create my own one which can work like split function ?

Well, I am not asking for the code, am asking for the "way" of doing it.

Link to comment

This can help you understanding:

function string.explode(self, separator) 
    Check("string.explode", "string", self, "ensemble", "string", separator, "separator") 
  
    if (#self == 0) then return {} end 
    if (#separator == 0) then return { self } end 
  
    return loadstring("return {\""..self:gsub(separator, "\",\"").."\"}")() 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...