Template:Str index any/doc

The Template:str_index_any extracts a specified nth character from a string, even allowing for accented letters or diacritics to be included in the string. The string can be any length, but position n (parameter 2) is limited to 500 at most.

Usage

 * = Returns the n-th character of text.

Supports a larger character set, allowing the text to have accented letters or other diacritical marks. Returns an error message for unknown characters. Returns &amp;#32; for a blank space, which can be converted to a simple space by xspace.

Examples

 * → R
 * 0 → 0
 * 0 → 0
 * 0 → 0
 * 0 → 0
 * 0 → 0

The last example shows extraction of letter "b" with string length as 1. The prior example extracts a blank but considers the length as 5 for the 5 characters "&amp;#32;" even though there is only 1 space, and hence, 9 &rarr; 5. If surrounded by 2 other characters, then the length might be totalled incorrectly as 7 (rather than 3 characters):


 * 2 → 2
 * 2 → 2
 * 2 → 2
 * XX → XX

The same string-length problem occurs when using template Str index. There might be other quirks as well, but most cases work as expected.