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
m m
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
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> characters from the start of the string.
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.


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 ===
* 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.
* Fast: uses no other templates.


=== Examples ===
=== Examples ===
Line 17: Line 21:
*<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 ===
* {{Tl|Trunc}} - which is almost identical.
* {{Tlx|Trunc|<string>|<count>}} - truncate right-side of string
* {{Tl|Str right}}
* {{Tlx|Str right|<string>|<count>}} - extract remainder of string
* {{Tl|Str rightc}}
* {{Tlx|Str rightc|<string>|<count>}} - extract right-side of string
* {{Tlx|Str len|<string>}} - get numeric length of string (can be over 300 long)


<includeonly>
<includeonly>

Revision as of 13:11, 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>). Use 999 (or such) to get entire string.

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 over 601 characters long.
  • Fast: 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 | foo }}
  • {{Str left| lorem ipsum dolor sit amet | }}
  • {{Str left| lorem ipsum dolor sit amet }} → l

See also

  • {{Trunc|<string>|<count>}} - truncate right-side of string
  • {{Str right|<string>|<count>}} - extract remainder of string
  • {{Str rightc|<string>|<count>}} - extract right-side of string
  • {{Str len|<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.