Zum Inhalt springen

Modul:Detect singular: Unterschied zwischen den Versionen

check for multiple QIDs
(escape asterisk)
(check for multiple QIDs)
Zeile 8: Zeile 8:


local function countMatches(s, pattern)
local function countMatches(s, pattern)
local count = 0
local dbg, count = mw.ustring.gsub(s, pattern, 'ASTERISK')
_, count = mw.ustring.gsub(s, pattern, '')
mw.log(dbg)
return count
return count
end
end
Zeile 33: Zeile 33:
local hasBreak = mw.ustring.find(s,'<%s*br')
local hasBreak = mw.ustring.find(s,'<%s*br')
local hasBullets = checkBullets and countMatches(s,'%*+') > 1
local hasBullets = checkBullets and countMatches(s,'%*+') > 1
local multipleQids = mw.ustring.find(s,'Q%d+[%p%s]+Q%d+') -- has multiple QIDs in a row
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