Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Str left/doc: Difference between revisions

Template page
indented Usage line; noted 999 gets entire string; stops at limit of 500 but no message will be shown; put See-also text describing each link
Restore appearance like documentation pages of similar templates. Remove superfluous, technical, or repeated parts.
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
__NOTOC__<!--suppress Table of Contents as typical in docs-->
 
=== Usage ===
=== Usage ===


::<code>{{Tlx|Str left|<string>|<count>}}</code>
: <code>{{Tlx|Str left|<string>|<count>}}</code>


Gives the <count> substring of characters from the start of the string (the substring has length <count>). Use 999 (or such) to get entire string.
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.
If <count> is invalid or empty, an empty string is returned. If undefined, it defaults to 1.


=== Limitations ===
=== 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 over 601 characters long.
* 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.
* Fast: uses no other templates.
* Inexpensive (uses no other templates).


=== Examples ===
=== Examples ===
Line 18: Line 18:
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | 10 }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | 10 }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | 10 }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | 10 }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | 1 }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | 1 }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | 1 }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | 1 }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | foo }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | foo }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet | }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet | }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet }}
*<tt><nowiki>{{Str left| lorem ipsum dolor sit amet }}</nowiki></tt> &rarr; {{Str left| lorem ipsum dolor sit amet }}
<!--DON'T SHOW:  Test of 605 long: {{Str left
|....:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8....:....9....:....0....:....1....:....2....:....3....:....4....:....5....:....6....:....7....:1...8....:1...9....:1...0....:....1....:....2....:....3....:....4....:....5....:....6....:....7....:2...8....:2...9....:2...0....:....1....:....2....:....3....:....4....:....5....:....6....:3...7....:3...8....:3...9....:..400....:....1....:....2....:....3....:....4....:....5....:....6....:....7...4:....8...4:....9...4:..500....:....1....:....2....:....3....:....4....:....5....:....6....:....7...5:....8...5:....9...5:..600....: |605}} -->


=== See also ===
=== See also ===
* {{Tlx|Trunc|<string>|<count>}} - truncate right-side of string
* {{Tl|Trunc|<string>|<count>}} - truncate right-side of string
* {{Tlx|Str right|<string>|<count>}} - extract remainder of string
* {{Tl|Str right|<string>|<count>}} - extract remainder of string
* {{Tlx|Str rightc|<string>|<count>}} - extract right-side of string
* {{Tl|Str rightc|<string>|<count>}} - extract right-side of string
* {{Tlx|Str len|<string>}} - get numeric length of string (can be over 300 long)
* {{Tl|Str len|<string>}} - get numeric length of string (can be over 300 long)


<includeonly>
<includeonly>

Revision as of 15:28, 11 October 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 | }}
  • {{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)


Cookies help us deliver our services. By using our services, you agree to our use of cookies.