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

From Ava Zinn Wiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
m (iw)
m (51 revisions)
 
(26 intermediate revisions by 19 users not shown)
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
 +
{{Lua|Module:String}}
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
  
=== Usage ===
+
== Usage ==
  
: <code>{{Tlx|Str right|<string>|<offset>}}</code>
+
: {{tlx|str right|<string>|<offset>}}
  
 
Gives the characters from <offset> to the end of the string.
 
Gives the characters from <offset> to the end of the string.
  
If <count> is invalid, empty or undefined, this template goes berserk, so don't do that.
+
A negative <offset> is treated the same as zero, which simply returns the original string.
  
=== Limitations ===
+
If <offset> is longer than <string> then this returns an empty string.
* 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.
 
  
=== Examples ===
+
If <offset> is invalid, empty or undefined, this template goes berserk, so please avoid.
  
*<tt><nowiki>{{Str right| lorem ipsum dolor sit amet | 10 }}</nowiki></tt> &rarr; {{Str right| lorem ipsum dolor sit amet | 10 }}
+
===Examples===
*<tt><nowiki>{{Str right| lorem ipsum dolor sit amet | 1 }}</nowiki></tt> &rarr; {{Str right| lorem ipsum dolor sit amet | 1 }}
+
* <code><nowiki>{{str right |Lorem ipsum dolor sit amet |10}}</nowiki></code> &rarr; {{str right |Lorem ipsum dolor sit amet |10}}
*<tt><nowiki>{{Str right| lorem ipsum dolor sit amet | 0 }}</nowiki></tt> &rarr; {{Str right| lorem ipsum dolor sit amet | 0 }}
+
* <code><nowiki>{{str right |Lorem ipsum dolor sit amet |1}}</nowiki></code> &rarr; {{str right |Lorem ipsum dolor sit amet |1}}
*<tt><nowiki>{{Str right |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}}
+
* <code><nowiki>{{str right |Lorem ipsum dolor sit amet |0}}</nowiki></code> &rarr; {{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> &rarr; {{str right |nocategory=true |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 |99}}
  
=== See also ===
+
== TemplateData ==
* {{Tl|Trunc|<string>|<count>}} - truncate right-side of string
+
 
* {{Tl|Str left|<string>|<count>}} - extract left-side substring
+
{{TemplateDataHeader}}
* {{Tl|Str rightc|<string>|<count>}} - extract right-side of string
+
<templatedata>
* {{Tl|Str len|<string>}} - get numeric length of string (can be over 300 long)
+
{
* {{Tl|Title disambig text|<string>}} - Extract ''disambig'' from page titles of the form ''Title (disambig)''
+
        "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>
 
<includeonly>
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
+
<!----CATEGORIES BELOW THIS LINE, PLEASE:---->
 
[[Category:String manipulation templates]]
 
[[Category:String manipulation templates]]
  
[[es:Plantilla:Str right]]
+
[[bn:টেমপ্লেট:Str right]]
[[id:Templat:Str right]]
 
[[it:Template:Str right]]
 
[[ru:Шаблон:Str right]]
 
 
</includeonly>
 
</includeonly>

Latest revision as of 08:34, 5 December 2016

Gnome-utilities-terminal.svg This template uses (or will be using) Lua programming language.

Please see Wikipedia:Lua if you want to learn more about Lua or help convert other templates.

Usage[edit]

{{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[edit]

  • {{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 ipsum dolor sit amet |0}}Expression error: Unrecognized punctuation character "{".
  • {{str right |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 |99}}Expression error: Unrecognized punctuation character "{".

TemplateData[edit]

This is the TemplateData documentation for this template used by VisualEditor and other tools.

Str right

Gives the characters from <offset> to the end of the string.

Template parameters

ParameterDescriptionTypeStatus
String1

The string to be trimmed

Default
empty
Example
empty
Auto value
empty
Stringrequired
Count2

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.

Default
empty
Example
empty
Auto value
empty
Numberrequired

See also[edit]