跳转到内容

模块:StringTPC

来自TPC
Harry00025留言 | 贡献2026年5月16日 (六) 09:17的版本 (Harry00025移动页面模块:Split模块:StringTPC

此模块的文档可以在模块:StringTPC/doc创建

-- 本模块使用deepseek生成,Harry00025复核 26/5/16

local p = {}

p.a = function(frame)
	local A = frame.args[1]
	local B = frame.args[2]
    local count = 0
    local pos = 1
    
    -- 使用 string.find 循环查找
    while pos <= #A do
        local start_pos, end_pos = string.find(A, B, pos, true)  -- true 表示纯文本匹配
        if start_pos then
            count = count + 1
            pos = end_pos + 1  -- 移动到匹配结束后的位置(不重叠)
        else
            break
        end
    end
    
    return count
end

return p