What I’m trying to achieve:
I am trying to get the letters of a string based off their position in the string.
From the example above, lets say I want the 6th and 7th letter in the string. I would like for the script to return those two letters (Which would be L and E). How can I go about doing this in an efficient way?
What if I wanted to replace those two letters with something like “XY” instead of “LE”?
Sorry for replying again, I forgot the whole second half of what I was trying to do.
you can use string.sub and string.gsub combined to do that
example:
local ExampleString = "EXAMPLESTRING"
local ReplaceWith = "XY"
local LettersToReplace = string.sub(ExampleString, 6, 7) -->> LE
local ReplacedString = string.gsub(ExampleString, LettersToReplace, ReplaceWith)
print(ReplacedString) -->> EXAMPXYSTRING
this might be a bit more complicated than string.sub