Module:Str find word: Difference between revisions

Content deleted Content added
explain (debug): -- never. 22Mar2023 checkExplain(newArgs) see /sandbox developments.
m Simplified code, primarily by eliminating a few sources of redundancy
Tag: Reverted
Line 79:
hitCount = 0
sWordlist = tArgs.sep .. sWordlist .. tArgs.sep
local eSep = escape_word(tArgs.sep)
eSep = escape_word(tArgs.sep)
local patstring = '%f[^' .. eSep .. '][^' .. eSep .. ']+%f[' .. eSep .. ']'
if yesno(tArgs.explain, false) then
Line 142 ⟶ 141:
-- note 2: empty AND-wordlist => True by logic (because: not falsified)
local function checkANDwords(sourceWordTable, andWordTable)
local result1bAND = true
local bANDtHits = {}
local tHitsresult1 = nil
 
bAND = true
tHits = {}
result1 = nil
if #andWordTable > 0 then
for i, word in ipairs(andWordTable) do
Line 160 ⟶ 156:
end
end
else
bAND = true
end
 
Line 174 ⟶ 168:
-- note 2: while just one hitword is a True result, the hittable contains all words found
local function checkORwords(sourceWordTable, orWordTable)
local result1bOR = false
local bORtHits = {}
local tHitsresult1 = nil
 
bOR = false
tHits = {}
result1 = nil
if #orWordTable > 0 then
for i, word in ipairs(orWordTable) do
Line 208 ⟶ 199:
return tArgs.no or ''
else -- True
ifreturn tArgs.yes ==or nil thensYesList
return sYeslist
else -- some |yes= value is entered, could be ''
return tArgs.yes
end
end
end
Line 285 ⟶ 272:
if yesno(tArgs.explain, false) then
if (tArgs.yes ~== '') and (tArgs.no == nil'') then
report.xpYesNoBothBlank()
if (tArgs.yes == '') and (tArgs.no == '') then
report.xpYesNoBothBlank()
end
end
if warningIMaxWordsReached ~= nil then
Line 365 ⟶ 350:
sReturn = p._main(tArgs)
if warningIMaxWordsReached ~= nil then
local preview = require('Module:If preview')
sReturn = sReturn .. preview._warning({warningIMaxWordsReached})