Something like string.replace(txt, "hello", "world")
Forum
![>](img/i_next.png)
![>](img/icons/cs2d.png)
![>](img/i_next.png)
![>](img/i_next.png)
String Replace
4 replies![To the start](img/i_first.png)
![Previous](img/i_prev.png)
![Next](img/i_next.png)
![To the start](img/i_last.png)
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
![To the start](img/i_first.png)
![Previous](img/i_prev.png)
![Next](img/i_next.png)
![To the start](img/i_last.png)