LUA replace instances of string -
i have string x = "a b c d e f g e b" , trying replace every instance of x b x character letter z let's say, above should x = z c d e f g z. have looked in examples mention specific characters replacement string.gsub, how can above done?
you may use
string.gsub(x, "%a b", "z") where %a matches letter.
see more on lua pattern here.
x = [[a b c d e f g e b]] res, _ = string.gsub(x, "%a b", "z") print(res) -- z c d e f g z
Comments
Post a Comment