Exercises
- Locate the standard string manipulation library in the Lua reference manual. Learn about
string.gmatch
,string.gsub
, and pattern matching. What pattern represents all non-space characters? - Using
string.gmatch
and a genericfor
loop, reverse the sentence “C++ loves Lua.” The output should be “Lua loves C++.” - Can you use
string.gsub
and achieve the same with one line of code?