Шаблон:Str sub new/док

Iz Vojne Enciklopedije
< Шаблон:Str sub new
Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted
(разл) ← Старија измена | Тренутна верзија (разл) | Новија измена → (разл)
Пређи на навигацију Пређи на претрагу

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted

This template selects a sub-string from the target string based on selected indices. The indices are 1-based. If the end index is omitted, it returns the rest of the string. One can also specify negative indices, in which case the substr is selected by counting from the end of the string.

Usage

{{str sub new|target_string|start_index|end_index}}
{{str sub new|s=target_string|i=start_index|j=end_index}}

Examples

Unnamed parameters

{{str sub new|1234567890|3|7}}

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted

{{str sub new|1234567890|3|-3}}

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted

{{str sub new|1234567890|3}}

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted

{{str sub new|1234567890|12}}

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted

Named parameters

{{Str sub new|s=abcd=fgh|i=3|j=7}}

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted

Equivalent to:

{{#invoke:string|sub|s=abcd=fgh|i=3|j=7}}

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted

Named parameters are required if the target string contains an equals sign, where unnamed or numbered parameters will not work as expected:

{{str sub new|abcd=fgh|3|7}}

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted

{{str sub new|1=abcd=fgh|2=3|3=7}}

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted

See also

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permitted