I have a string for my tutorial system and at the end I specify what action it is, example: {Text}
I want everything after a certain word to be taken out and stored as a variable, whenever I do {Arrow} I want to be able to specify the position so how can I get that?
Example: “textblabla! {Arrow=10,0,10}”
You can use capture groups in string pattern matching!
local s = [[textblalbla! {Arrow=10,0,10}]]
local pattern = "{(.-)=(.-)}"
local name, value = s:match(pattern)
print(name, value)
Or if you have multiple occurences:
local s = [[textblalbla! {Arrow=10,0,10} {Test=ayyy}]]
local pattern = "{(.-)=(.-)}"
for name, value in s:gmatch(pattern) do
print(name, value)
end
1 Like
Thank you so much for such a thorough response that can cover my all my cases!
1 Like
No problem! Ask away if you want an explanation of the string pattern, or maybe just look around on the internet for a reference for string patterns 