Editing Module:String
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 59: | Line 59: | ||
Parameters | Parameters | ||
s: The string to return a subset of | s: The string to return a subset of | ||
i: The | i: The fist 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. | ||
Line 407: | Line 407: | ||
if plain then | if plain then | ||
pattern = str._escapePattern( pattern ) | pattern = str._escapePattern( pattern ) | ||
replace = | replace = mw.ustring.gsub( replace, "%%", "%%%%" ) --Only need to escape replacement sequences. | ||
end | end | ||
Line 512: | Line 512: | ||
end | end | ||
--[[ | --[[ | ||
Helper function that populates the argument list given that user may need to use a mix of | Helper function that populates the argument list given that user may need to use a mix of | ||
Line 620: | Line 583: | ||
]] | ]] | ||
function str._escapePattern( pattern_str ) | function str._escapePattern( pattern_str ) | ||
return | return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" ) | ||
end | end | ||
return str | return str |