Template:Str right
| Warning | This template is used on approximately 7,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
{{#ifeq:str right |doc
|
{{#ifeq:show |show
|| icon | This is a documentation subpage for Template:Terminate sentence It may contain usage information, categories and other content that is not part of the original {{#if: |{{{text2}}} |{{#if: |{{{text1}}} |{{#ifeq:Template |User |template template page |{{#if:Template |template page|article}}}}}}}}. |
}}{{#if:|
|{{#ifexist:Template:Str right
| [[Category:{{#switch:Template |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]]
|
}}
}}
|
}}
| File:Lua-Logo.svg | This template uses Lua: |
Usage
{{str right|<string>|<offset>}}
Gives the characters from <offset> to the end of the string.
A negative <offset> is treated the same as zero, which simply returns the original string.
If <offset> is longer than <string> then this returns an empty string.
If <offset> is invalid, empty or undefined, this template goes berserk, so please avoid.
Examples
{{str right |Lorem ipsum dolor sit amet |10}}→ {{safesubst:#ifexpr: 10 < 0
|Lorem ipsum dolor sit amet |{{safesubst:#ifexpr: 10+1 > 26 | | Lorem ipsum dolor sit amet }} }}
{{str right |Lorem ipsum dolor sit amet |1}}→ {{safesubst:#ifexpr: 1 < 0
|Lorem ipsum dolor sit amet |{{safesubst:#ifexpr: 1+1 > 26 | | Lorem ipsum dolor sit amet }} }}
{{str right |Lorem ipsum dolor sit amet |0}}→ {{safesubst:#ifexpr: 0 < 0
|Lorem ipsum dolor sit amet |{{safesubst:#ifexpr: 0+1 > 26 | | Lorem ipsum dolor sit amet }} }}
{{str right |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 |99}}→ {{safesubst:#ifexpr: 99 < 0
|123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 |{{safesubst:#ifexpr: 99+1 > 101 | | 123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 }} }}
{{str right |#123456|1}}→ {{safesubst:#ifexpr: 1 < 0
|#123456 |{{safesubst:#ifexpr: 1+1 > 7 | |
- 123456 }}
}}
{{str right |#123|1}}→ {{safesubst:#ifexpr: 1 < 0
|#123 |{{safesubst:#ifexpr: 1+1 > 4 | |
- 123 }}
}}
TemplateData
|=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AStr+right%7CStr+right%7CStr+right%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|S|s}}ee a monthly parameter usage report] for {{#if:Str right|Template:Str right|this template}} in articles{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Str right|its|this}} TemplateData}}.
|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AStr+right%7CStr+right%7CStr+right%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report]{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Str right|its|this}} TemplateData}}
|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AStr+right%7CStr+right%7CStr+right%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report] for {{#if:Str right|Template:Str right|Template:Str right}}{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Str right|its|this}} TemplateData}}.
|#default=[1]{{#ifeq:{{safesubst:#switch: y |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Str right|its|this}} TemplateData}} }}|This is the {{#if:|TemplateData|TemplateData}} for this template used by TemplateWizard, VisualEditor and other tools. {{#switch:
|=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AStr+right%7CStr+right%7CStr+right%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|S|s}}ee a monthly parameter usage report] for {{#if:Str right|Template:Str right|this template}} in articles{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Str right|its|this}} TemplateData}}.
|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AStr+right%7CStr+right%7CStr+right%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report]{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Str right|its|this}} TemplateData}}
|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AStr+right%7CStr+right%7CStr+right%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}} |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|no|P|p}}arameter usage report] for {{#if:Str right|Template:Str right|Template:Str right}}{{#ifeq:{{safesubst:#switch: y
|no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Str right|its|this}} TemplateData}}.
|#default=[2]{{#ifeq:{{safesubst:#switch: y |no |n |f |false |off |0 = no | = no |¬ = no |yes |y |t |true |on |1 = yes |#default = no
}}|yes| based on {{#if:Str right|its|this}} TemplateData}} }}}}
TemplateData for Str right
{{#if:
| {{{demospace}}}
| {{#ifeq:Template|Template
| template
| other
}}
}}
| template = {{safesubst:#if:{{safesubst:#ifeq:Str rig|sandbox|1}}{{safesubst:#ifeq:Str right|doc|1}}||
}} | other | #default = }} <templatedata> {
"description": "Gives the characters from <offset> to the end of the string.",
"params": {
"1": {
"label": "String",
"description": "The string to be trimmed",
"type": "string",
"required": true
},
"2": {
"label": "Count",
"description": "The index of the character to trim from. Negative values are treated as 0, see {{safesubst:#switch:{{safesubst:#if:|a}}{{safesubst:#iferror:{{safesubst:#ifexpr:>0|b}}|c}}
|ab=Lua error in Module:Ustring at line 23: bad argument #2 to 'sub' (number expected, got string). |ac= |a= |}} to trim the right n characters. If its greater than the string length returns the empty string.",
"type": "number",
"required": true
}
}
} </templatedata>
See also
- {{str rightc}}
- {{str left}}
{{safesubst:#if:{{safesubst:#ifeq:Str rig|sandbox|1}}{{safesubst:#ifeq:Str right|doc|1}}|| }}