Asphalt Wiki
Asphalt Wiki


[edit] Template-info.png Template documentation
Ambox content.png This template is used on 2,100+ pages.
To avoid any disruptions and to save server load, any changes should first be tested in this template's /sandbox or /testcases subpage, or in your own user space. The tested changes can then be added in one single edit to this template. As a courtesy to other users, please discuss any changes at the talk page before implementing them.

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.

Some separators have to be escaped with a percent sign to be accepted, as they are magic characters for Lua patterns: ^$()%.[]*+-?) (see example below and Lua reference on Mediawiki for further details).


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}}


  • {{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

Escaping magic characters:

  • {{Remove last word|Nissan GT-R (R35) (upgrades)|sep=%(}} → Nissan GT-R (R35)

Caution: The last space after (R35) is not trimmed. This can lead to unexpected results if used with expressions like {{#ifeq: ...}}.

  • Solution with {{Trim}} to remove leading and trailing spaces:
    {{Trim|{{Remove last word|Text (1) (2)|sep=%(}}}}Next → Text (1)Next

See also