lua 怎么判断字符串A是否包含字符串B
可以使用字符串函数string.find()来判断字符串A是否包含字符串B。如果找到了字符串B,则返回B在A中的起始位置和结束位置;如果没有找到,则返回nil。示例代码如下:
local strA = "hello world"
local strB = "world"
if string.find(strA, strB) then
print("strA contains strB")
else
print("strA does not contain strB")
end
输出结果为:
strA contains strB
原文地址: https://www.cveoy.top/t/topic/cpLb 著作权归作者所有。请勿转载和采集!