Solved Splitting strings

Discussion in 'Rust Development' started by TrustZan, Feb 5, 2015.

  1. Code:
        webrequests.EnqueueGet(    url, function(code, response)
                command, args = response:match("([^:]+),([^:]+)")
                print(command)
                print(args)
            end, self.Object)
    
    Obviously the above function does not work and I'm extremely simple minded at regex, can anyone put me in the right direction for simply splitting at a colon and referencing the first and second values?

    An example in PHP would be

    Code:
    list($command, $args) = explode(":", response);
    
    Moving on to next issue: http://oxidemod.org/threads/no-access-to-hooks.6709/
     
  2. Code:
    local function split(str, sep)
        local tbl = {}
        for word in string.gmatch(str, "[^"..sep.."]+") do
            table.insert(tbl, word)
        end
        return tbl
    endlocal string = "this is:your string"
    local splitted = split(string, ":")-- output
    for key, value in pairs(splitted) do
        print(key, value)
    end