How can Lua determine if this text exists?

In Lua, you can use the string.find function to determine if a string contains a specific text. This function will return the position of the text’s first occurrence in the string, or nil if it is not found.

Below is a sample code:

local str = "Hello, Lua!"

if string.find(str, "Lua") then
    print("字符串中包含Lua")
else
    print("字符串中不包含Lua")
end

The output shows that the string contains Lua.

广告
Closing in 10 seconds
bannerAds