Template:Sub/doc
Kaonekelo
This is a documentation subpage for Template:Sub. It may contain usage information, categories and other content that is not part of the original template page. |
Extracts a substring of a string.
Usage
[kulemba source]{{sub|text|number of characters removed from the start|maximum length}}
"{{sub|20090624130510|0|0}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|20090624130510|0|3}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|20090624130510|8|0}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|20090624130510|8|3}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|café noir|0|4}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|café noir|1|3}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|café noir|3|2}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|café noir|4|2}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|22:06, 12 July 2010 User|19|5}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|22:06, 2 July 2010 User|19|4}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123|0|200}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123|1|200}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|1*3456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123|1|200}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
.
Limitation
[kulemba source]<nowiki>...</nowiki>
and <nowiki />
tags and their content are internally replaced by a code, which may affect the result:
"{{sub|<nowiki/>*café noir|1|9}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
."{{sub|*café noir|1|9}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
.
Automatic newline
[kulemba source]Due to the automatic newline feature/bug a newline is added before any "*", "#", ":", and ";" in the substring, except when the substring starts at the start of the string:
"{{sub|*test|1|4}}"
gives"Lua error: bad argument #1 to 'sub' (string expected, got nil)."
.
See also
[kulemba source]