As the title says... Chat on...

User avatar
By knack
#57012 Hello.

I have few problems with gsub

I have a table with key/value, the key name its used as keyword for change to his value in a text var (with html)

that not work (matching /*key*/)
Code: Select all 
    for k,v in pairs(tKeys) do
        local repl = "/%*" .. k .. "-%*/"
        new_tpl = oldtpl.gsub(oldtpl,  repl, tKeys[k])
    end


some values change wrong things too

that works matching /*somekeyname*/
Code: Select all    for k,v in pairs(tKeys) do
        local repl = "/%somekeyname-%*/"
        new_tpl = oldtpl.gsub(oldtpl,  repl, tKeys[somekeyname])
    end


Any idea?

Checking other things i trying match [ssid]

new_tpl = oldtpl.gsub(oldtpl, "%[ssid%]", value)
or
new_tpl = oldtpl.gsub(oldtpl, "%[ssid-%]", value)

not work...
what i missed? ins't % the escape character?
User avatar
By knack
#57027 forget this, i concentrate in gsub and ins't the problem(at least not before solve others), have two other problems, first a stupid error looping new_tpl var that not save the changes, and second when i read the file (chunk), use gsub, get size for read the second chunk and of course the size after use gsub ins't the right for continue reading the file :oops: i got messy html code not for wrong use of gsub.

working too much hours isn't productive! take a break!