Modulo:String2/pagipadasan: Paggiddiatan a nagbaetan dagiti rebision

Content deleted Content added
Pinabaro manipud iti Module:String2/1007393418
Pinabaro manipud iti Module:String2/1016876661
Linia 1:
-- Version 2021-02-17
 
local p = {}
 
Line 277 ⟶ 275:
result = mw.ustring.gsub(source_str, "["..chars.."]", '')
return result;
end
 
--[[
Match any
Returns the index of the first given pattern to match the input. Patterns must be consecutively numbered.
Returns the empty string if nothing matches for use in {{#if:}}
 
Usage:
{{#invoke:String2|matchAll|source=123 abc|456|abc}} returns '2'.
 
Parameters:
source: the string to search
plain: A flag indicating that the patterns should be understood as plain text. defaults to true.
1, 2, 3, ...: the patterns to search for
]]
function p.matchAny(frame)
local source_str = frame.args['source'] or error('The source parameter is mandatory.')
local l_plain = p._getBoolean( frame.args['plain'] or true )
for i = 1, math.huge do
local pattern = frame.args[i]
if not pattern then return '' end
if mw.ustring.find(source_str, pattern, 1, l_plain) then
return tostring(i)
end
end
end