Template:Str rightc
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
{{Str rightc |1= |2= |3= }}
{{Str rightc|<string>|<count>}}
{{Str rightc|<string>|<count>|<result if empty>}}
Template parameters
- TemplateData
TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.
Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either useTemplateData=1
or useTemplateData=only
on the /doc
subpage and transcluding it with {{Documentation}} into the template. <nowiki>
-tags can be wrapped around the arguments, if required, to avoid templates being expanded.
Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw <templatedata>
-tags into the Wikitext of the template, as described in various Wikipediae.
Wikipedia's help about TemplateData • Commons-specific information
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.
Parameter | Description | Type | Status | |
---|---|---|---|---|
string | 1 | The string to return the rightmost characters of | Unknown | optional |
count | 2 | The number of characters to return | Number | required |
default | 3 | Result if string is empty | Unknown | optional |
Additional information
The template is intended to be used in the following namespaces: no namespace specified
The template is intended to be used by the following user groups: no user group specified
Relies on:
See also
Trimming templates:
- {{Trunc}} – To trim down to a specified number of characters.
- {{Trim}} — To trim any leading or trailing whitespace.
- {{Str left}} – To trim down to a specified number of characters, or duplicate the string to a specified number.
- {{Str right}}
Analyzing templates:
- {{Str endswith}} – To check if a string ends with a given string.
- {{Str find}} – Returns the numerical location of a given string in a string, up to 50 characters.
- {{Str len}} – Returns a string's length. Can count up to 500 characters.
String length comparison templates:
- {{Str ≤ len}} – To check if a string is "shorter or equally long" or "longer" than a given length.
Technical stuff:
- mw:Help:Magic words – About
{{padleft:|}}
. - mw:Help:Extension:ParserFunctions – About
{{#titleparts:|}}, {{#expr:|}}, {{#ifeq:|}},
etc. - Module:String - Script with native string parsing
Localization
This template is not intended to be localized.
Examples
{{Str rightc| lorem ipsum dolor sit amet | 10 }}
→ r sit amet{{Str rightc| lorem ipsum dolor sit amet | 1 }}
→ t{{Str rightc| lorem ipsum dolor sit amet | 0 }}
→{{Str rightc| | 1 | empty }}
→ empty{{Str rightc |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 | 99}}
→ 3456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1