Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K 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 right: Difference between revisions

Template page
m Unprotected Template:Str right: Consensus at WP:ANI appears to be that these should be unprotected. Unprotecting without prejudice to new consensus emerging at WT:HRT: I won't consider it wheel-warring if anyone re-protects, etc. using [[WP:TW|TW]
m Protected "Template:Str right": Widely used template ([Edit=Allow only template editors and administrators] (indefinite) [Move=Allow only template editors and administrators] (indefinite))
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<includeonly>{{{{{|safesubst:}}}Str sub long|nocategory={{{nocategory|}}}|{{{1}}}|{{{2}}}|{{{{{|safesubst:}}}#expr:{{{{{|safesubst:}}}Str len|nocategory={{{nocategory|}}}|{{{1}}}}}-{{{2}}}}}}}</includeonly><noinclude>
<includeonly>{{{{{|safesubst:}}}#ifexpr: {{{2|0}}} < 0
|{{{1}}}  
|{{{{{|safesubst:}}}#ifexpr: {{{2|0}}}+1 > {{{{{|safesubst:}}}#invoke:String|len|s={{{1}}}}} | |
{{{{{|safesubst:}}}#Invoke:String|sub|s={{{1}}}|{{{{{|safesubst:}}}#expr:{{{2|0}}}+1}}|nocategory={{{nocategory|}}}}} }}
}}</includeonly><noinclude>
{{Documentation}}
{{Documentation}}
</noinclude>
</noinclude>

Latest revision as of 08:13, 29 August 2024

Template documentation[ view · edit · history · purge ]
This documentation is transcluded from Template:Str right/doc.


Note: if you want to edit this template, first try your modifications on {{Str right/sandbox}}.You can then test your edits in {{Str right/testcases}}.
When the new version is ready, you can move it to the main template.

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 don't do that.

Limitations

  • Up to 100 chararacters in the input string. If possible, first check length of input string using {{<string>}}. Using strings longer than 100 characters may result in the error "max index is 100 for str_sub".
  • Limited set of characters.
  • Expensive.

Examples

  • {{Str right| lorem ipsum dolor sit amet | 10 }} → m dolor sit amet
  • {{Str right| lorem ipsum dolor sit amet | 1 }} → orem ipsum dolor sit amet
  • {{Str right| lorem ipsum dolor sit amet | 0 }} → lorem ipsum dolor sit amet
  • {{Str right |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 | 99}} → 3456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1

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}}
  • {{Strip}} – To strip (remove) a given number of characters from the beginning/end of the string

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.

Sandboxes and test cases:

Technical stuff:

w:ar:قالب:Str right w:cy:Nodyn:Str right w:es:Plantilla:Str right w:id:Templat:Str right w:ja:Template:Str right w:ru:Шаблон:Str right w:ur:Template:Str right

Cookies help us deliver our services. By using our services, you agree to our use of cookies.