Something like string.replace(txt, "hello", "world")
Forum
Scripts
String Replace
String Replace
4 replies
1

Something like string.replace(txt, "hello", "world")
1
2
2
print(string.gsub("hello world", "hello", "world"))
-- world world
Works fine when I use strings, but it does not work when replacing using a tabled dictionary.
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
replace_from={"lol","cats"}
replace_to=""
str="my cats are pretty awesome and lols"
for _,item in ipairs(replace_from) do
	str=str:gsub(item,replace_to)
end
table1 = {"a","b"}
table2 = {"1","2"}
a->1
b->2
1

Offline