Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I separate stringValues?

Hello,

I am wondering how I can separate stringValues?

If I have a stringValue that has: "100 | Title | Views" All separated with a | is there a way I can make an array separating each of the bits of text between the "|"?

And also, how do I access different parts of an array?

Thanks, Ethan!

3 comments

0

I don't see anything about seperating it between the

1 answer

try looking at these pages

https://www.lua.org/pil/20.2.html

http://lua-users.org/wiki/PatternsTutorial

http://wiki.roblox.com/index.php/String_pattern

code:

local raw = "100 | Title | Views"
local data = {}

for word in string.gmatch(raw, '([^ | ]+)') do -- looks for a pattern in the string
    table.insert(data, word) --add the separated version to data
end

--we can see if this worked by unpacking it
print(unpack(data)) 

output: 100 Title Views

1 comment

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.