Content deleted Content added
No edit summary Tags: Reverted Mobile edit Mobile web edit |
m Reverted edits by 66.49.135.40 (talk) to last version by GKFX |
||
Line 10:
; ignore_errors
: If set to 'true' or 1, any error condition will result in an empty string being returned rather than an error message.
; error_category
: If an error occurs, specifies the name of a category to include with the error message. The default category is {{clc|Errors reported by Module String}}.
; no_category
: If set to 'true' or 1, no category will be added if an error is generated.
Unit tests for this module are available at [[Module:String/testcases]].
=
This function returns the length of the target string.
Usage:
: <code><nowiki>{{#invoke:</nowiki>String|len|''target_string''}}</code>¿▼
OR
¡\ <code><nowiki>{{#invoke:</nowiki>String|len|s= ''target_string'' }}</code>▼
Parameters:
; s
: The string whose length to report
Examples:
* <code><nowiki>{{#invoke:String|len| abcdefghi }}</nowiki></code> → {{#invoke:String|len| abcdefghi }}
* <code><nowiki>{{#invoke:String|len|s= abcdefghi }}</nowiki></code> → {{#invoke:String|len|s= abcdefghi }}
== sub ==
This function returns a substring of the target string at specified inclusive, one-indexed indices.
Line 43 ⟶ 48:
: <code><nowiki>{{#invoke:</nowiki>String|sub|''target_string''|''start_index''|''end_index''}}</code>
OR
: <code><nowiki>{{#invoke:</nowiki>String|sub|s= ''target_string'' |i= ''start_index'' |j= ''end_index'' }}</code>
Parameters:
; s
Line 70 ⟶ 74:
* <code><nowiki>"{{#invoke:String|sub|s= abcdefghi |i= 3 |j= 4 }}"</nowiki></code> → "{{#invoke:String|sub|s= abcdefghi |i= 3 |j= 4 }}"
This function implements the features of {{tl|str sub old}} and is kept in order to maintain these older templates. It returns a substring of the target string starting at a specified index and of a specified length.
Usage:
: <code><nowiki>{{#invoke:</nowiki>String|sublength|s= ''target_string'' |i= ''start_index'' |len= ''length'' }}</code>
|