I have a string like this
str = '["username"] = "user";
["deepscan"] = "true";
["token"] = true;
["password"] = "krghfkghkfghf";
["uploadMethod"] = "JSON";
["serviceIsRunning"] = {};
["host"] = "sample.com";
["instance_ID"] = 405454058;'
I would like the pattern match ["password"] = and have it replace only the string in between the ";' that would be '"krghfkghkfghf" in this instance.
str = str:gsub('(%["password"%]%s*=%s*").-"','%1'..new_pwd:gsub('%%','%%%%')..'"')