To concatenate strings, use the operator ..
:
local c = “Hey “ local b = c..”nmaper!” print(b)
The output will be as follows:
Hey nmaper!
There will be a lot of occasions when you will need to know if a certain string is a substring of another string object, for example, to match the response of a network request. We can do this with Lua in a few different ways with the help of the following functions:
string.find(s, pattern [, init [, plain]]) string.match(s, pat) string.gmatch(s, pat)
The function string.find
returns the position of the beginning and end of the string occurrence, or nil if not found. It should be used when we need to find a string and the position offsets are needed:
> print(string.find("hello", "ello")) 2 5
On the other hand, if you don’t need the position indexes, you could use the function string.match
, as follows:
If string.match(resp...