Modul:Detect singular: Unterschied zwischen den Versionen

fix
(fix gsub)
(fix)
Zeile 5: Zeile 5:
local function plainFind(s, sub)
local function plainFind(s, sub)
return mw.ustring.find(s, sub, 1, true)
return mw.ustring.find(s, sub, 1, true)
end
local function countMatches(s, pattern)
local count = 0
_, count = mw.ustring.gsub(s, pattern, '')
return count
end
end


Zeile 26: Zeile 32:
local hasAnd = mw.ustring.find(s,'%Aand%A')
local hasAnd = mw.ustring.find(s,'%Aand%A')
local hasBreak = mw.ustring.find(s,'<%s*br')
local hasBreak = mw.ustring.find(s,'<%s*br')
local hasBullets = checkBullets and mw.ustring.gsub(s,'*+','') > 1
local hasBullets = checkBullets and countMatches(s,'*+') > 1
return not (hasComma or hasList or hasAnd or hasBreak or hasBullets)
return not (hasComma or hasList or hasAnd or hasBreak or hasBullets)
end
end
Anonymer Benutzer