Jump to content

Template:Remove last word/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
expand usage and examples, note use of Module:String
m add high-use template
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{high-use}}
{{Documentation subpage}}
{{Documentation subpage}}
<!--Categories where indicated at the bottom of this page, please; interwikis at Wikidata (see [[Wikipedia:Wikidata]])-->
<!--Categories where indicated at the bottom of this page, please; interwikis at Wikidata (see [[Wikipedia:Wikidata]])-->
Line 28: Line 29:
{{String-handling templates}}
{{String-handling templates}}


<includeonly>
<includeonly>{{Sandbox other||
<!--Categories below this line, please; interwikis at Wikidata-->
<!--Categories below this line, please; interwikis at Wikidata-->
[[Category:String manipulation templates]]
[[Category:String manipulation templates]]
</includeonly>
}}</includeonly>

Latest revision as of 00:03, 21 May 2023

This template removes the last word of the first parameter, i.e. the last non-space token after the last space. Use |1= for the first parameter if the string may contain an equals sign (=). By default, words are delimited by spaces, but the optional parameter |sep= can set the separator to any character.

Usage

[edit]

One parameter (space as separator):

  • {{Remove last word|string}}
  • {{Remove last word|1=string}}

Two parameters (user-defined character as separator):

  • {{Remove last word|string|sep=character}}
  • {{Remove last word|1=string|sep=character}}

Examples

[edit]
  • {{Remove last word|Remove last word}} → Remove last
  • {{Remove last word|Remove last}} → Remove
  • {{Remove last word|Remove}} → Remove
  • {{Remove last word|Remove, last word|sep=,}} → Remove
  • {{Remove last word|Foo-bar|sep=-}} → Foo
  • {{Remove last word|1=len = a+b|sep==}} → len

See also

[edit]