模块:String:修订间差异
imported>A2569875 小无编辑摘要 |
imported>Great Brightstar |
||
| 第146行: | 第146行: | ||
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns | * http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Patterns | ||
* http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns | * http://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Ustring_patterns | ||
]] | ]] | ||
function str.match( frame ) | function str.match( frame ) | ||
| 第380行: | 第381行: | ||
return result; | return result; | ||
end | |||
--[[ | |||
simple function to pipe string.rep to templates. | |||
]] | |||
function str.rep( frame ) | |||
local repetitions = tonumber( frame.args[2] ) | |||
if not repetitions then | |||
return str._error( 'function rep expects a number as second parameter, received "' .. ( frame.args[2] or '' ) .. '"' ) | |||
end | |||
return string.rep( frame.args[1] or '', repetitions ) | |||
end | end | ||