I'm not yet very familiar with the patterns in Lua's string.gsub function.

If I have a string like this:

Fishing Lure(+100 Fishing Skill)(1 hour)

and I want extract only the string "1 hour", what pattern should I use?

3 Replies 3

What are your exact requirements for the resulting string, e.g. do you want the second bracketed value? or all bracketed values?

I want the second bracket value.

local s = "Fishing Lure(+100 Fishing Skill)(1 hour)"

local x = s:match(".+%((.-)%)$")
print(x)

local y = s:gsub(".+%((.-)%)$","%1")
print(y)

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.