模块:StringTPC:修订间差异
外观
Harry00025(留言 | 贡献) 小无编辑摘要 标签:已被回退 |
Harry00025(留言 | 贡献) 撤销Harry00025(讨论)的修订版本1404 标签:撤销 |
||
| 第1行: | 第1行: | ||
-- 本模块使用deepseek生成,Harry00025复核 26/5/16 | |||
local p = {} | local p = {} | ||
p.split = function(frame) | p.split = function(frame) | ||
| 第21行: | 第21行: | ||
return count | return count | ||
end | end | ||
return p | return p | ||
2026年5月16日 (六) 09:39的最新版本
此模块的文档可以在模块:StringTPC/doc创建
-- 本模块使用deepseek生成,Harry00025复核 26/5/16
local p = {}
p.split = 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