Laakari
|
  |
| Joined: 07 Aug 2014 |
| Total Posts: 17362 |
|
|
| 14 Apr 2016 09:54 PM |
Like in Python:
string = "Hello,there!"
newArray = string.split(",")
print(newArray)
>>> '["Hello", "there!"]'
|
|
|
| Report Abuse |
|
|
|
| 14 Apr 2016 09:55 PM |
Not completely sure in all honesty, but you can always use string.find and string.sub to cut it. Take a look for yourself: http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation |
|
|
| Report Abuse |
|
|
Laakari
|
  |
| Joined: 07 Aug 2014 |
| Total Posts: 17362 |
|
|
| 14 Apr 2016 09:59 PM |
Nah I don't see it.
Dang, that would simplify a script I'm making using chatted events.
Oh well, I guess I will use that method.
|
|
|
| Report Abuse |
|
|
|
| 14 Apr 2016 10:11 PM |
function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end
tabbleOfSplitStringWithAComma = ("a,bb,ccc,ddd"):split(",")
|
|
|
| Report Abuse |
|
|
gskw
|
  |
| Joined: 05 Jan 2013 |
| Total Posts: 1364 |
|
|
| 14 Apr 2016 11:47 PM |
| ^ You can't change the string table |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2016 01:17 AM |
http://lua-users.org/wiki/SplitJoin
for i in string.gmatch(example, "%S") do print(i) end
or for words for i in string.gmatch(example, "%S+") do print(i) end |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 15 Apr 2016 01:25 AM |
local myString = "a,bb,ccc,ddd"
split = function(str, mark) local tab = {} for val in str:gmatch("[^%"..mark.."]+") do tab[#tab + 1] = val end return tab end
local myTab = split(myString,",")
for i,v in next, myTab do print(v) end
|
|
|
| Report Abuse |
|
|
|
| 15 Apr 2016 04:02 AM |
| thanks for the credit mong. |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2016 04:19 AM |
You can change the string value.
|
|
|
| Report Abuse |
|
|