Difference between revisions of "Template:Str index"
From Ava Zinn Wiki
m (moved User:Dragons flight/string index to Template:Str index) |
Aeverinezinn (talk | contribs) m (31 revisions) |
||
(23 intermediate revisions by 11 users not shown) | |||
Line 1: | Line 1: | ||
− | <includeonly>{{ | + | <includeonly>{{str ≥ len |
− | + | | 1 = {{{1|}}} | |
− | + | | 2 = {{{2|0}}} | |
− | + | | 3 = {{str index/logic|*{{str left|{{{1|}}}|{{{2|0}}}}}*|{{str left|{{{1|}}}|{{#expr:{{{2|0}}}-1}}}}}} | |
− | + | | 4 = {{FormattingError|((str index)): String is not long enough.}} | |
+ | }}</includeonly><noinclude> | ||
+ | {{documentation}} | ||
+ | </noinclude> |
Latest revision as of 17:59, 10 December 2015
Usage[edit]
{{str index|text|number}} = Returns the number-th character of text.
Base 1: the first character is numbered 1, and so on. Any leading or trailing whitespace is removed from the string before searching.
If the requested position is negative, this function will search the string counting from the last character. In other words, number = -1 is the same as asking for the last character of the string.
A requested position equal to zero or with a value longer than the string will generate an error.
This function will properly return a space character (' ') if the selected position contains a space.
Examples[edit]
-
{{str index|0123456789ABCDEF|15}}
→ Character not recognized by string_index -
{{str index|0123456789ABCDEF|18}}
→ ((str index)): String is not long enough.
See also[edit]
|
The above documentation is transcluded from Template:Str index/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |