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

From Ava Zinn Wiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
(noted "Example of error messages")
(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)
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 ===
 +
* 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>}}.
 +
* Limited set of characters, perhaps.
 +
* Expensive: invokes 7 templates (Str index, Str left, Str len, Str len/core, Str sub, Str ≥ len, etc.).
  
 
=== Examples ===
 
=== Examples ===
Line 14: Line 19:
 
*<tt><nowiki>{{Str right| lorem ipsum dolor sit amet | 10 }}</nowiki></tt> &rarr; {{Str right| lorem ipsum dolor sit amet | 10 }}
 
*<tt><nowiki>{{Str right| lorem ipsum dolor sit amet | 10 }}</nowiki></tt> &rarr; {{Str right| lorem ipsum dolor sit amet | 10 }}
 
*<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 }}
 +
 
; Example of error messages:
 
; 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 }}
 
*<tt><nowiki>{{Str right| lorem ipsum dolor sit amet | foo }}</nowiki></tt> &rarr; {{Str right| lorem ipsum dolor sit amet | foo }}
 
=== Limitations ===
 
 
* Up to 50 char strings. Limited set of characters, perhaps.
 
* Expensive.
 
  
 
=== See also ===
 
=== See also ===
* {{Tl|Trunc}}
+
* {{Tlx|Trunc|<string>|<count>}} - truncate right-side of string
* {{Tl|Str left}}
+
* {{Tlx|Str left|<string>|<count>}} - extract left-side substring
* {{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)
 +
: '''Reminder''': Str_right may abort if <string> has over 50 characters.
  
 
<includeonly>
 
<includeonly>

Revision as of 08:47, 11 October 2009

Usage

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

Gives the characters from <offset> to the end of the string. Use 0 (zero) to get entire 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 "max index is 50 for str_sub", so the input string should not have over 50 characters.

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|<string>}}.
  • Limited set of characters, perhaps.
  • Expensive: invokes 7 templates (Str index, Str left, Str len, Str len/core, Str sub, Str ≥ len, etc.).

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 "{".
Example of error messages
  • {{Str right| lorem ipsum dolor sit amet | foo }}Expression error: Unrecognized word "foo".

See also

  • {{Trunc|<string>|<count>}} - truncate right-side of string
  • {{Str left|<string>|<count>}} - extract left-side substring
  • {{Str rightc|<string>|<count>}} - extract right-side of string
  • {{Str len|<string>}} - get numeric length of string (can be over 300 long)
Reminder: Str_right may abort if <string> has over 50 characters.