-- gsub returns the new string and the number of replacements local s = "one two two three" local result, count = string.gsub(s, "two", "2") print(result) print(count)
string.gsub replaces all matches