How would I separate a section of string out from say, an embedded language or something similar to that, I have tried to figure this out but to no avail.
Example: Say I had a string and it was output('Hi') and I wanted to grab and separate the content inside of the parameters of output using a function that would separate out strings by detecting 2 patterns of symbols such as ‘[{’ and ‘}]’, how would I go about doing this?
local Open = "[%[%{]"
local Close = "[%]%}]"
local StringPattern = Open.."(.-)"..Close
local function SepareteString(String)
local tab = {}
for Str in string.gmatch(String, StringPattern) do
table.insert(tab, Str)
end
return tab
end
local String = "Hi there {Yeah it Worked!} 5325 [25435]"
print(unpack(SepareteString(String)))
--[[
Output:
Yeah it Worked! 25435
--]]```
You can use either [ or } to separete strings using this function i quickly wrote up.