有人可以帮我解决这个问题吗:
s_test = "this is a test string this is a test string "
function String.Wholefind(Search_string, Word)
_, F_result = string.gsub(Search_string, '%f[%a]'..Word..'%f[%A]',"")
return F_result
end
A_test = String.Wholefind(s_test,"string")
output: A_test = 2
所以边界模式发现整个单词没有问题,gsub 计算整个单词没有问题但是如果搜索字符串有数字怎么办?
s_test = " 123test 123test 123"
B_test = String.Wholefind(s_test,"123test")
output: B_test = 0
如果数字不在搜索字符串的开头或结尾,似乎可以使用