In Lua, there are many functions that are useful to manipulate strings. We can use the string.reverse
function if we need to reverse a string.
string = string.reverse(string)
The function only needs a valid string as a mandatory parameter.
The reverse
function will reverse the string given as input.
In this example, we will reverse the string "Hello, Educative!"
:
ourstring = "Hello, Educative!"print(string.reverse(ourstring))
!evitacudE ,olleH