Kossrifle
Kossrifle

Reputation: 23

What are Lua's string.gsub pattern rules?

Here is the current script that have running:

var_name="[Clan] Imposter"

     while var_name:find("[Clan]")~=nil do 
          var_name=var_name:gsub("[Clan]", "") 
     end

print(var_name)

I was expecting var_name to be "Imposter" however the result was "[] Imposter".

How do I get the result from this function to be "Imposter"?

Upvotes: 2

Views: 1131

Answers (1)

lhf
lhf

Reputation: 72422

You need to escape square brackets in patterns: "%[Clan%]".

Upvotes: 5

Related Questions