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

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -