I am attempting to isolate Training Session, Nicklaus_s, and TypicallyShadow. So Type would be equal to Training Session, Host would be equal to Nicklaus_s, and CoHost would be equal to TypicallyShadow.
I understand how string.gsub() works, I just am unable to figure out the correct patterns to use. The enters (whitespace) in my Description is the ultimate problem.
I’m not familiar with gsub, but perhaps you could try this alternative method:
local str = ... -- Your string
local lines = string.split(str, '\n')
local data = {}
for _,line in pairs(lines) do
local Type,value = string.split(line, ": ")
data[line] = value
end
... -- Do whatever with data
I haven’t tested it, and I wrote in the devforum. I know this is much longer than it needs to be, but it’s just an alternative way. Data should be something MicrosoftWindowsRBX said.
local data = {}
local str = [[Type: Training Session
Host: Nicklaus_s
Co-Host: TypicallyShadow]]
for i in str:gmatch("[^\n]+") do
local v1, v2 = i:match("(.+): (.+)")
data[v1] = v2
end
for i, v in pairs(data) do
print(i, "\t", v)
end
--[[
Type Training Session
Host Nicklaus_s
Co-Host TypicallyShadow
--]]
Basically gmatch will capture anything in a set that’s not a newline (\n) and return it. Then using match will capture before and after the colon (:). I hope this helps