|
|
(3 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | {{Lua|Module:String}} | + | <includeonly>{{{{{|safesubst:}}}#ifexpr: {{{2|0}}} < 0 |
− | <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
| + | |{{{1}}} |
− | | + | |{{{{{|safesubst:}}}#ifexpr: {{{2|0}}}+1 > {{{{{|safesubst:}}}#invoke:String|len|s={{{1}}}}} | | |
− | == Usage ==
| + | {{{{{|safesubst:}}}#Invoke:String|sub|s={{{1}}}|{{{{{|safesubst:}}}#expr:{{{2|0}}}+1}}|nocategory={{{nocategory|}}}}} }} |
− | | + | }}</includeonly><noinclude> |
− | : {{tlx|str right|<string>|<offset>}} | + | </noinclude> |
− | | |
− | 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===
| |
− | * <code><nowiki>{{str right |Lorem ipsum dolor sit amet |10}}</nowiki></code> → {{str right |Lorem ipsum dolor sit amet |10}}
| |
− | * <code><nowiki>{{str right |Lorem ipsum dolor sit amet |1}}</nowiki></code> → {{str right |Lorem ipsum dolor sit amet |1}}
| |
− | * <code><nowiki>{{str right |Lorem ipsum dolor sit amet |0}}</nowiki></code> → {{str right |Lorem ipsum dolor sit amet |0}}
| |
− | * <code><nowiki>{{str right |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 |99}}</nowiki></code> → {{str right |nocategory=true |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 |99}}
| |
− | | |
− | * <code><nowiki>{{str right |#123456|1}}</nowiki></code> → {{str right |#123456|1}}
| |
− | * <code><nowiki>{{str right |#123|1}}</nowiki></code> → {{str right |#123|1}}
| |
− | | |
− | | |
− | == TemplateData ==
| |
− | | |
− | {{TemplateDataHeader}} | |
− | <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 {{str rightc}} to trim the right n characters. If its greater than the string length returns the empty string.",
| |
− | "type": "number",
| |
− | "required": true
| |
− | }
| |
− | }
| |
− | } | |
− | </templatedata>
| |
− | | |
− | == See also == | |
− | * {{tl|str rightc}}
| |
− | * {{tl|str rightmost}}
| |
− | * {{tl|str left}}
| |
− | | |
− | {{String-handling templates |trim}}
| |
− | | |
− | <includeonly>{{Sandbox other|| | |
− | <!----CATEGORIES BELOW THIS LINE, PLEASE:----> | |
− | [[Category:String manipulation templates]]
| |
− | }}</includeonly>
| |