Template:Str left/doc: Difference between revisions
Template page
More actions
→Examples: initial caps for "Lorem" to make single character results clearer; add extra example with count = 40 to show effect of count > stringlength |
m interwiki |
||
| Line 36: | Line 36: | ||
[[es:Plantilla:Str left]] | [[es:Plantilla:Str left]] | ||
[[eo:Ŝablono:Lin mald]] | [[eo:Ŝablono:Lin mald]] | ||
[[hsb:Předłoha:Str left]] | |||
[[id:Templat:Str left]] | [[id:Templat:Str left]] | ||
[[lv:Veidne:Str left]] | [[lv:Veidne:Str left]] | ||
Revision as of 10:19, 4 March 2010
Usage
{{Str left|<string>|<count>}}
Gives the <count> substring of characters from the start of the string (the substring has length <count>).
If <count> is invalid or empty, an empty string is returned. If undefined, it defaults to 1.
Limitations
- Length to 500: The maximum substring stops at 500 long, yet gives no error message. Only 500 characters can be extracted even if the <string> is longer.
- Inexpensive (uses no other templates).
Examples
- {{Str left| Lorem ipsum dolor sit amet | 10 }} → Lorem ipsu
- {{Str left| Lorem ipsum dolor sit amet | 1 }} → L
- {{Str left| Lorem ipsum dolor sit amet | 0 }} →
- {{Str left| Lorem ipsum dolor sit amet | }} →
- {{Str left| Lorem ipsum dolor sit amet }} → L
- {{Str left| Lorem ipsum dolor sit amet | 40 }} → Lorem ipsum dolor sit ametLorem ipsum do
See also
- [[:<count>:Template:Trunc|{{<string>}}]] - truncate right-side of string
- [[:<count>:Template:Str right|{{<string>}}]] - extract remainder of string
- [[:<count>:Template:Str rightc|{{<string>}}]] - extract right-side of string
- {{<string>}} - get numeric length of string (can be over 300 long)