Template:Str index

From Path of Exile Wiki
Jump to navigation Jump to search
Template documentation[view] [edit] [history] [purge]

Lua logo

This template uses the following modules:

This template returns a single character from the target string at the given position.

Usage

{{str index|target_string|position_index}}

Parameters

target_string
The string to search
position_index
The index for the character to return

The first character has an index value of 1.

If one requests a negative value, this function will select a character by counting backwards from the end of the string. In other words pos = -1 is the same as asking for the last character.

A requested value of zero, or a value greater than the length of the string returns an error.

Examples

  • {{str index|Great sentence!|4}} yields: a
  • {{str index|Great sentence!|-2}} yields: e
This template was adapted from Template:Str index on Wikipedia.
Adaptation is noted for reference and attribution only. This template may differ from the original in function or in usage.