Jump to content
Toggle menu
  • 3 articles
  • 75 files
  • 7 users
  • 37.9K 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 rightc/doc: Difference between revisions

Template page
from https://secure.wikimedia.org/wikipedia/en/w/index.php?title=Template:Str_rightc/doc&oldid=400090880
 
code instead of tt tag
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{TemplateBox
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
  |1        = 1
  |1label-en= string
  |1d-en    = The string to return the rightmost characters of
  |1aliases = <!-- List of aliases, separated by / (a slash) -->
  |1type    = <!-- number, string, string/wiki-user-name, string/wiki-page-name, string/line; unknown -->
  |1def    = <!-- default value for the parameter -->
  |1stat    = optional


=== Usage ===
  |2        = 2
  |2label-en= count
  |2d-en    = The number of characters to return
  |2aliases =  
  |2type    = number
  |2def    =  
  |2stat    = required


  |3        = 3
  |3label-en= default
  |3d-en    = Result if string is empty
  |3aliases =
  |3type    =
  |3def    =
  |3stat    = optional
  |name              = Str rightc
  |desc-en            = This template gives a substring of length <count> of characters from the right-side end of the string. If the parameter 1 <string> is empty, then immediately returns with parameter 3 (or nothing), and skips all the complex processing usually needed to extract a substring.
  |usage-notes        =
: <code>{{Tlx|Str rightc|<string>|<count>}}</code>
: <code>{{Tlx|Str rightc|<string>|<count>}}</code>
: <code>{{Tlx|Str rightc|<string>|<count>|<result if empty>}}</code>
: <code>{{Tlx|Str rightc|<string>|<count>|<result if empty>}}</code>
  |namespace          =
  |usergroup          =
  |shorthand          =
  |mustbesubst        =
  |setscats          =
  |placement          =
  |example            =
  |example-value      =
  |relieson          =
* {{tl|str sub long}}
* {{tl|str len}}
* {{tl|max}}
  |seealso            = {{String templates see also}}
  |print              =
  |type              =
  |i18n-method        = -
  |i18n-desc          =
  |i18n-subpage      =
  |i18n-mediawiki-msg =
  |useTemplateData    = only
}}


Gives a substring of length <count> of characters from the right-side end of the string. If the parameter 1 <string> is empty, then immediately returns with parameter 3 (or nothing), and skips all the complex processing usually needed to extract a substring.
== Examples ==
 
If <count> is invalid, empty or undefined, this template goes berserk, so don't do that.
=== Limitations ===
* Up to 100 chararacters in the input string. If possible, first check length of input string using {{Tl|Str len|<string>}}. Using strings longer than 100 characters may result in the error '''''"<font color=#CC1100>max index is 100 for str_sub</font>"'''''.
* Limited set of characters.
* Expensive (if used too many times per page, generates "Wikimedia Foundation Server Error").
* Returning parameter 3, when parameter 1 is empty, was added 8 May 2010.
 
=== Examples ===
 
*<tt><nowiki>{{Str rightc| lorem ipsum dolor sit amet | 10 }}</nowiki></tt> &rarr; {{Str rightc| lorem ipsum dolor sit amet | 10 }}
*<tt><nowiki>{{Str rightc| lorem ipsum dolor sit amet | 1 }}</nowiki></tt> &rarr; {{Str rightc| lorem ipsum dolor sit amet | 1 }}
*<tt><nowiki>{{Str rightc| lorem ipsum dolor sit amet | 0 }}</nowiki></tt> &rarr; {{Str rightc| lorem ipsum dolor sit amet | 0 }}
*<tt><nowiki>{{Str rightc| | 1 | empty }}</nowiki></tt> &rarr; {{Str rightc| | 1 |empty }}
*<tt><nowiki>{{Str rightc |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 | 99}}</nowiki></tt> &rarr; {{Str rightc |nocategory=true |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 | 99}}
 
=== See also ===
{{String templates see also}}


*<code><nowiki>{{Str rightc| lorem ipsum dolor sit amet | 10 }}</nowiki></code> &rarr; {{Str rightc| lorem ipsum dolor sit amet | 10 }}
*<code><nowiki>{{Str rightc| lorem ipsum dolor sit amet | 1 }}</nowiki></code> &rarr; {{Str rightc| lorem ipsum dolor sit amet | 1 }}
*<code><nowiki>{{Str rightc| lorem ipsum dolor sit amet | 0 }}</nowiki></code> &rarr; {{Str rightc| lorem ipsum dolor sit amet | 0 }}
*<code><nowiki>{{Str rightc| | 1 | empty }}</nowiki></code> &rarr; {{Str rightc| | 1 |empty }}
*<code><nowiki>{{Str rightc |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 | 99}}</nowiki></code> &rarr; {{Str rightc |nocategory=true |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 | 99}}
<includeonly>
<includeonly>
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
<!-- CATEGORIES HERE, THANKS -->
[[Category:String manipulation templates]]
[[Category:String manipulation templates]]
[[es:Plantilla:Str rightc]]
[[id:Templat:Str rightc]]
</includeonly>
</includeonly>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.