「モジュール:String」の版間の差分

(1版 をインポートしました)
bsd>Trappist the monk
15行目: 15行目:
     error_category: If an error occurs, specifies the name of a category to
     error_category: If an error occurs, specifies the name of a category to
         include with the error message.  The default category is
         include with the error message.  The default category is
         [Category:モジュールStringのエラー].
         [Category:Errors reported by Module String].


     no_category: If set to 'true' or 1, no category will be added if an error
     no_category: If set to 'true' or 1, no category will be added if an error
59行目: 59行目:
Parameters
Parameters
     s: The string to return a subset of
     s: The string to return a subset of
     i: The fist index of the substring to return, defaults to 1.
     i: The first index of the substring to return, defaults to 1.
     j: The last index of the string to return, defaults to the last character.
     j: The last index of the string to return, defaults to the last character.


407行目: 407行目:
if plain then
if plain then
pattern = str._escapePattern( pattern )
pattern = str._escapePattern( pattern )
replace = mw.ustring.gsub( replace, "%%", "%%%%" ) --Only need to escape replacement sequences.
replace = string.gsub( replace, "%%", "%%%%" ) --Only need to escape replacement sequences.
end
end


540行目: 540行目:
function str._error( error_str )
function str._error( error_str )
local frame = mw.getCurrentFrame()
local frame = mw.getCurrentFrame()
local error_category = frame.args.error_category or 'モジュールStringのエラー'
local error_category = frame.args.error_category or 'Errors reported by Module String'
local ignore_errors = frame.args.ignore_errors or false
local ignore_errors = frame.args.ignore_errors or false
local no_category = frame.args.no_category or false
local no_category = frame.args.no_category or false
548行目: 548行目:
end
end


local error_str = '<strong class="error">モジュールStringのエラー: ' .. 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 = '[[Category:' .. error_category .. ']]' .. error_str
error_str = '[[Category:' .. error_category .. ']]' .. error_str
583行目: 583行目:
]]
]]
function str._escapePattern( pattern_str )
function str._escapePattern( pattern_str )
return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" )
return ( string.gsub( pattern_str, "[%(%)%.%%%+%-%*%?%[%^%$%]]", "%%%0" ) )
end
end


return str
return str
匿名利用者