Difference between revisions of "Template:Str right/doc"

From Ava Zinn Wiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
(indented Usage line; noted zero gets entire string; limit of 50 else may get message "max index is 50 for str_sub"; put example for 0 as "lorem all with zero"; 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 right|<string>|<offset>}}</code>
+
: <code>{{Tlx|Str right|<string>|<offset>}}</code>
  
Gives the characters from <offset> to the end of the string. Use 0 (zero) to get entire string.
+
Gives the characters from <offset> to the end of the string.
  
If <count> is invalid, empty or undefined, this template goes berserk (repeats error message forty times), so don't do that. Using <offset> over 50, can give the error '''''"<font color=#CC1100>max index is 50 for str_sub</font>"''''', so the input string should not have over 50 characters.
+
If <count> is invalid, empty or undefined, this template goes berserk, so don't do that.
  
 
=== Limitations ===  
 
=== Limitations ===  
* Up to 50 chararacters in the input string. Longer strings will cause an error message. If possible, first check length of input string using {{Tlx|str_len|<string>}}.
+
* Up to 50 chararacters in the input string. Longer strings will cause an error message. If possible, first check length of input string using {{Tl|Str len|<string>}}. Using <offset> over 50, can give the error '''''"<font color=#CC1100>max index is 50 for str_sub</font>"''''', so the input string should not have over 50 characters.
 
* Limited set of characters, perhaps.
 
* Limited set of characters, perhaps.
* Expensive: invokes 7 templates (Str index, Str left, Str len, Str len/core, Str sub, Str ≥ len, etc.).
+
* Expensive.
  
 
=== Examples ===
 
=== Examples ===
Line 20: Line 20:
 
*<tt><nowiki>{{Str right| lorem ipsum dolor sit amet | 1 }}</nowiki></tt> &rarr; {{Str right| lorem ipsum dolor sit amet | 1 }}
 
*<tt><nowiki>{{Str right| lorem ipsum dolor sit amet | 1 }}</nowiki></tt> &rarr; {{Str right| lorem ipsum dolor sit amet | 1 }}
 
*<tt><nowiki>{{Str right| lorem all with zero. | 0 }}</nowiki></tt> &rarr; {{Str right| lorem all with zero. | 0 }}
 
*<tt><nowiki>{{Str right| lorem all with zero. | 0 }}</nowiki></tt> &rarr; {{Str right| lorem all with zero. | 0 }}
 
; Example of error messages:
 
*<tt><nowiki>{{Str right| lorem ipsum dolor sit amet | foo }}</nowiki></tt> &rarr; {{Str right| lorem ipsum dolor sit amet | foo }}
 
  
 
=== See also ===
 
=== See also ===
* {{Tlx|Trunc|<string>|<count>}} - truncate right-side of string
+
* {{Tl|Trunc|<string>|<count>}} - truncate right-side of string
* {{Tlx|Str left|<string>|<count>}} - extract left-side substring
+
* {{Tl|Str left|<string>|<count>}} - extract left-side substring
* {{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)
: '''Reminder''': Str_right may abort if <string> has over 50 characters.
 
  
 
<includeonly>
 
<includeonly>

Revision as of 11:18, 11 October 2009

Usage

<code>{{Str right|<string>|<offset>}}</code>

Gives the characters from <offset> to the end of the string.

If <count> is invalid, empty or undefined, this template goes berserk, so don't do that.

Limitations

  • Up to 50 chararacters in the input string. Longer strings will cause an error message. If possible, first check length of input string using {{Str len}}. Using <offset> over 50, can give the error "max index is 50 for str_sub", so the input string should not have over 50 characters.
  • Limited set of characters, perhaps.
  • Expensive.

Examples

  • {{Str right| lorem ipsum dolor sit amet | 10 }}Expression error: Unrecognized punctuation character "{".
  • {{Str right| lorem ipsum dolor sit amet | 1 }}Expression error: Unrecognized punctuation character "{".
  • {{Str right| lorem all with zero. | 0 }}Expression error: Unrecognized punctuation character "{".

See also

  • {{Trunc}} - truncate right-side of string
  • {{Str left}} - extract left-side substring
  • {{Str rightc}} - extract right-side of string
  • {{Str len}} - get numeric length of string (can be over 300 long)