string substitution - Replace a substring in Lua with a pattern -


i have string

     str = '["username"] = "user";      ["deepscan"] = "true";      ["token"] = true;      ["password"] = "krghfkghkfghf";      ["uploadmethod"] = "json";      ["serviceisrunning"] = {};      ["host"] = "sample.com";      ["instance_id"] = 405454058;' 

i pattern match ["password"] = , have replace string in between ";' '"krghfkghkfghf" in instance.

local function replacepass(configstr, newpass)     return configstr:gsub("(%[\"password\"%]%s*=%s*)%b\"\"", "%1\"" .. newpass .. "\"") end 

that won't work if password contains double quote inside.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -