Jump to content

How can I separate variable?


Recommended Posts

  • Moderators
local var1 = "Bobby_Bob"

local lengthofvar1 = #var1 -- returns: 9
local positionof_  = var1:find("_") -- returns: 6
local first_part   = var1:sub(1, positionof_- 1) -- returns: Bobby
local second_part  = var1:sub(positionof_ + 1, lengthofvar1) -- returns: Bob

 

Edited by stPatrick
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...