Template:Str left/doc: Difference between revisions

From FamilySearch Wiki
(Created page with '{{Documentation subpage}} <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> === Usage === : <code>{{Tlx|Str left|<string>|<count>}}</code> Gives the <co…')
 
m (→‎See also: added nowiki)
 
Line 23: Line 23:


=== See also ===
=== See also ===
* {{Tl|Trunc|<string>|<count>}} - truncate right-side of string
* <nowiki>{{Tl|Trunc|<string>|<count>}}</nowiki> - truncate right-side of string
* {{Tl|Str right|<string>|<count>}} - extract remainder of string
* <nowiki>{{Tl|Str right|<string>|<count>}}</nowiki> - extract remainder of string
* {{Tl|Str rightc|<string>|<count>}} - extract right-side of string
* <nowiki>{{Tl|Str rightc|<string>|<count>}}</nowiki> - extract right-side of string
* {{Tl|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)



Latest revision as of 16:42, 12 January 2019

Usage[edit source]

{{Str left{{{4}}}{{{5}}}{{{6}}}{{{7}}}{{{8}}}{{{9}}}{{{10}}}{{{11}}}...}}

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[edit source]

  • 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[edit source]

  • {{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[edit source]

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