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.

lua demo:

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

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

javascript - Angular2 intelliJ config error.. Cannot find module '@angular/core' -