so im trying to make system that founds letter on a string with given number and replace it with another letter
for example i have a string that says "Hello!"then i want to replace its second letter with “H” so it should be like “HHllo!” how can i do that?
if you dont understand it im sorry my english isnt good
ok i try explain it better
yes i want to replace second letter of “Hello!” but i want to do it with a number
so that means if the number was 4 then i want to replace the fourth letter of “Hello!” with H
local function replace(word: string, pos: number, letter: char): string
local t = string.split(word, "")
t[pos] = letter
return table.concat(t, "")
end
print(replace("Hello!", 2, "H"))