PtokaX forum

Development Section => Your Developing Problems => Topic started by: deseven on 10 November, 2010, 22:20:52

Title: string.gsub with variables
Post by: deseven on 10 November, 2010, 22:20:52
Hello.
Code (lua) Select

CurrentMsg[3] = CurrentMsg[3]:gsub(ReplaceWhat[r],ReplaceWith[r])

All i got is just "malformed pattern (missing ']')"
I also tried to replace variables with functions and got "bad argument #2 to 'gsub' (string expected, got function)"

I don't want to use patterns, i want to use variables. Is there anything i can do with that?
Title: Re: string.gsub with variables
Post by: deseven on 11 November, 2010, 09:01:36
Thank you for your answer.
I found that the problem isn't with variables, the problem is with the values of that variables :)

If anyone curious, old values:
ReplaceWhat = { "[b]","[/b]","[u]","[/u]","[i]","[/i]","[c]","[/c]","[quote]","[/quote]" }

New values:
ReplaceWhat = { "%[b]","%[/b]","%[u]","%[/u]","%[i]","%[/i]","%[c]","%[/c]","%[quote]","%[/quote]" }