יחידה:String: הבדלים בין גרסאות בדף

אין תקציר עריכה
מ 16 גרסאות של הדף wikipedia:he:יחידה:String יובאו
 
(26 גרסאות ביניים של 12 משתמשים אינן מוצגות)
שורה 433: שורה 433:
     local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>';
     local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>';
     if error_category ~= '' and not str._getBoolean( no_category ) then
     if error_category ~= '' and not str._getBoolean( no_category ) then
        error_str = mw.title.getCurrentTitle().namespace .. '[[Category:' .. error_category .. ']]' .. error_str;
    if mw.title.getCurrentTitle().namespace ~= 10 then
        error_str = '[[Category:' .. error_category .. ']]' .. error_str;
        end
     end         
     end         
      
      
שורה 475: שורה 477:
   
   
Usage:
Usage:
{{#invoke:String|contains_any|string|search1|search2}}
{{#invoke:String|contains_any|string|search1|search2|search3...}}
   
   
Parameters
Parameters
שורה 519: שורה 521:
if not repval then return '' end
if not repval then return '' end
return string.rep( strval, repval )
return string.rep( strval, repval )
end
str.join = function(frame)
local res = {}
local sep = ', '
for k,v in pairs(frame.args) do
if k=='sep' then
sep = v
else
if #v>0 then -- avoid empty string
table.insert(res, v)
end
end
end
return table.concat( res, sep)
end
str.encode = function(frame)
return mw.text.encode( frame.args[1] or "" )
end
str["קידוד"] = str.encode
str['מיצוי מספר'] = function(frame)
local s = frame.args[1]
local def = frame.args[2] or ''
if not s then return def end
local int, frac = s:match('[^%d.-]*(%-?[%d,]*)(%.%d+)')
if int or frac then
int = string.gsub(int or '', ',', '') -- remove commas
frac = frac or ''
return int .. frac
end
int = s:match('[^%d.-]*(%-?[%d,]*)')
int = int and string.gsub(int or '', ',', '')
return int or def
end
end


return str
return str