Jump to content

Get a certain part of a string


Recommended Posts

Posted

Hey im trying to split a string into two parts the string will always have a space like this example:

"Data1 Data2"

How can i make it like this: local data1,data2 = Data1, Data2

i tried:

local data1, data2 = table.concat(thestring, ", ")

Found the answer: Use the Lua split function.

Posted

example:

local theString = "Data1 Data2" 
local data = split(theString, " ") 
--data[1] is now "Data1" and data[2] is "Data2" 
  

  • MTA Team
Posted

Or:

  
local theString = "Data1 Data2" 
local data1, data2 = unpack(split(theString," ")) 
  

Hope that helps you liam

  • MTA Team
Posted
Found the answer: Use the Lua split function.

He already solved his problem.

AFTER we told him.

Posted
Found the answer: Use the Lua split function.

He already solved his problem.

AFTER we told him.

No, actually he already solved it before anyone had posted ( I didn't post because it was already solved ).

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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