Jump to content

split suggestion


Recommended Posts

  • MTA Team
function splitf(input, separator)
    local output = split(input, separator)

    for index = 1, #output do
        local fragment = output[index]

        if fragment:match("^%d") then
            output[index] = tonumber(fragment:match("^%d+%.?%d+"))
        end
    end

    return output
end

Example:

output = {"Hello", "123", "World", "123prefix", "3.141wtf", "suffix456"}
1    Hello      string
2    123        number
3    World      string
4    123        number
5    3.141      number
6    suffix456  string

 

Link to comment
  • Recently Browsing   0 members

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