Changes

1,825 bytes added ,  01:57, 15 September 2021
m
→‎top: {{High-use}}
{{Documentation subpage}}
{{High-use}}
<!--Categories where indicated at the bottom of this page, please; interwikis at Wikidata (see [[Wikipedia:Wikidata]])-->
{{Shortcut|Template:lastw}}
{{Lua|Module:String}}

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

==Usage==
One parameter (space as separator):
* <code>'''{&#123;{{BASEPAGENAME}}|'''<var>string</var>'''}}'''</code>
* <code>'''{&#123;{{BASEPAGENAME}}|1='''<var>string</var>'''}}'''</code>

Two parameters (user-defined character as separator):
* <code>'''{&#123;{{BASEPAGENAME}}|'''<var>string</var>'''|sep='''<var>character</var>'''}}'''</code>
* <code>'''{&#123;{{BASEPAGENAME}}|1='''<var>string</var>'''|sep='''<var>character</var>'''}}'''</code>

==Examples==
* {{Tlc|{{BASEPAGENAME}}|}} → {{{{BASEPAGENAME}}|}}
* {{Tlc|{{BASEPAGENAME}}|Select last word}} → {{{{BASEPAGENAME}}|Select last word}}
* {{Tlc|{{BASEPAGENAME}}|Select last}} → {{{{BASEPAGENAME}}|Select last}}
* {{Tlc|{{BASEPAGENAME}}|Select}} → {{{{BASEPAGENAME}}|Select}}
* {{Tlc|{{BASEPAGENAME}}|Select, last word|sep{{=}},}} → {{{{BASEPAGENAME}}|Select, last word|sep=,}}
* <code>{&#123;{{BASEPAGENAME}}|Foo-bar|sep=-}}</code> → {{{{BASEPAGENAME}}|Foo-bar|sep=-}}
* <code>{&#123;{{BASEPAGENAME}}|1=len = a+b|sep==}}</code> → {{{{BASEPAGENAME}}|1=len = a+b|sep==}}

==See also==
* {{tl|First word}}
* {{tl|Sortname}}
{{String-handling templates}}

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