Module:ContainsString: Difference between revisions

From Trans People Together Wiki
No edit summary
No edit summary
Line 10: Line 10:
         return true
         return true
     else
     else
         return false
         return
     end
     end
end
end


return p
return p

Revision as of 17:29, 8 May 2025

Documentation for this module may be created at Module:ContainsString/doc

-- Module:Contains
local p = {}

-- Usage in wikitext: {{#invoke:ContainsString|contains|<full text>|<substring>}}
function p.contains(frame)
    local text   = frame.args[1] or ''
    local sub    = frame.args[2] or ''
    -- plain-text (no pattern) find
    if mw.ustring.find(text, sub, 1, true) then
        return true
    else
        return
    end
end

return p