Example : Photo I just want help with finding out how to make stuff happen to specific numbers or letters in text. Like if i want letter 1 to be bolded and letter 2 to be underlined or whatever. Please help :D
COMMUNITY QUESTION
Help with locating which letter or number in text is ordered 1 to last?
1 answer
There is a list of methods under the Lua name string. Which you can use to manipulate strings in a lot of ways.
If you think of a string as a table it makes more sense. Look at the following example:
local text = "Dulce et decorum est, pro patria mori."
for i = 1, string.len(text) do
print(string.sub(text, i, i)
end
-- prints D, u, l, c, e, [SPACE]... and so on
You could then replace all instances of the letter E with V.
local text = "Dulce et decorum est, pro patria mori."
local processedString = ""
for i = 1, string.len(text) do
if string.sub(text, i, i) == ("e" or "E") then
processedString ..= "v"
else
processedString ..= string.sub(text, i, i)
end
end
print(processedString) -- prints "Dulcv vt dvcorum..."
Read more about strings here.
This discussion is preserved as it was. New answers, comments, and votes are closed.
