Author Topic: string.gsub with variables  (Read 1676 times)

0 Members and 1 Guest are viewing this topic.

Offline deseven

  • Junior Member
  • **
  • Posts: 20
  • Karma: +4/-2
string.gsub with variables
« on: 10 November, 2010, 22:20:52 »
Hello.
Code: Lua
  1. CurrentMsg[3] = CurrentMsg[3]:gsub(ReplaceWhat[r],ReplaceWith[r])
  2.  
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?

PtokaX forum

string.gsub with variables
« on: 10 November, 2010, 22:20:52 »

Offline deseven

  • Junior Member
  • **
  • Posts: 20
  • Karma: +4/-2
Re: string.gsub with variables
« Reply #1 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:
Code: [Select]
ReplaceWhat = { "[b]","[/b]","[u]","[/u]","[i]","[/i]","[c]","[/c]","[quote]","[/quote]" }
New values:
Code: [Select]
ReplaceWhat = { "%[b]","%[/b]","%[u]","%[/u]","%[i]","%[/i]","%[c]","%[/c]","%[quote]","%[/quote]" }
« Last Edit: 11 November, 2010, 09:04:34 by deseven »

PtokaX forum

Re: string.gsub with variables
« Reply #1 on: 11 November, 2010, 09:01:36 »