【发布时间】:2015-02-12 22:46:19
【问题描述】:
我正在尝试编写一些代码来查看两个数据集并匹配它们(如果匹配),目前我正在使用 string.find 并且这有点工作但它非常严格。例如:它适用于 check1 但不适用于 check2/3,因为提要或其他单词中有空格。我喜欢在所有 3 个上返回一个匹配,但我该怎么做呢? (匹配超过 4 个字符,可能吗?)
check1 = 'jan'
check2 = 'janAnd'
check3 = 'jan kevin'
input = 'jan is friends with kevin'
if string.find(input.. "" , check1 ) then
print("match on jan")
end
if string.find( input.. "" , check2 ) then
print("match on jan and")
end
if string.find( input.. "" , check3 ) then
print("match on jan kevin")
end
PS:我尝试过 gfind、gmatch、match,但没有运气
【问题讨论】: