Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ReplaceOuterCharacters(s, replace, replaceWith)
- local characters = {};
- for i = 1, #s do
- characters[i] = s:sub(i, i)
- if i == 1 or i == #s then
- if (characters[i] == replace) then
- characters[i] = replaceWith;
- end
- end
- end
- local newString = "";
- for i = 1, #characters do
- newString = newString .. characters[i];
- end
- return newString;
- end
Advertisement
Add Comment
Please, Sign In to add comment