「モジュール:String」の版間の差分
ナビゲーションに移動
検索に移動
per edit request (permalink);
細 (1版 をインポートしました) |
bsd>Trappist the monk (per edit request (permalink);) |
||
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: | [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 | 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 = | 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 ' | 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"> | 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 | return ( string.gsub( pattern_str, "[%(%)%.%%%+%-%*%?%[%^%$%]]", "%%%0" ) ) | ||
end | end | ||
return str | return str |