Template:Str left/doc: Difference between revisions
Template page
More actions
m Interwiki |
|||
| Line 32: | Line 32: | ||
[[Category: String manipulation templates]] | [[Category: String manipulation templates]] | ||
[[ | [[de:Vorlage:Str left]] | ||
[[es:Plantilla:Str left]] | [[es:Plantilla:Str left]] | ||
[[ | [[eo:Ŝablono:Lin mald]] | ||
[[id:Templat:Str left]] | [[id:Templat:Str left]] | ||
[[lv:Veidne:Str left]] | |||
[[ja:Template:Str left]] | [[ja:Template:Str left]] | ||
[[pt:Predefinição:Str left]] | |||
[[ru:Шаблон:Str left]] | |||
</includeonly> | </includeonly> | ||
Revision as of 10:58, 11 December 2009
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
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)