Template talk:Remove first word
Text and/or other creative content from Template:Remove_first_word was copied or moved into incubator:Template:Wp/nod/remove_first_word with this edit. The former page's history now serves to provide attribution for that content in the latter page, and it must not be deleted as long as the latter page exists. |
Result string does not contain true spaces
editBecause of the way that the template works, the result string does not contain true spaces, so it cannot be fed into other templates when these look for true spaces, e.g. {{First word}} or {{Strfind short}}. Thus although this:
- {{Remove first word|This is some junk}} → is some junk
produces output which when finally displayed is the string "is some junk", it does not behave in the same way as this string before it is displayed. Note the differences between the following:
- {{First word|is some junk}} → is
- {{First word|{{Remove first word|This is some junk}}}} → is
- {{Strfind short|is some junk| |1}} → 3
- {{Strfind short|{{Remove first word|This is some junk}}| |1}} → 3
As far as I can tell, this is caused by the way that {{Str sub}} works; see Template talk:Str sub#Apparent space characters in the result.
This behaviour cost me several hours of debugging on a template I was trying to write, so I hope this note may save other people the same. Peter coxhead (talk) 09:32, 15 December 2011 (UTC)
- I noticed some problems with the "/any" version of this template which may be related to what you describe above.
- "
{{remove first word/any| foo bar baz }}
" → "bar baz" - "
{{remove first word/any| a b }}
" → "b"- Consequently, "
{{#ifeq: {{remove first word/any| a b }} | b | true | false }}
" returns "true"
- Consequently, "
- "
- They are a little different
- "
{{remove first word| foo bar baz }}
" → "bar baz" - "
{{remove first word| a b }}
" → "b"- Consequently, "
{{#ifeq: {{remove first word| a b }} | b | true | false }}
" returns "true"
- Consequently, "
- "
{{Remove first word| aa bb }}
" → "bb" - "
{{Remove first word| a b }}
" → "b"
- "
- The current behavior seems very confusing...Helder 13:24, 16 June 2012 (UTC)
Sep - several symbols
editOne should probably replace ^[^{{{sep|%s}}}]*{{{sep|%s}}}*
with ^[^{{{sep|%s}}}]*[{{{sep|%s}}}]*
(add []) to support sep=,;
- several symbols as possible separators. Wikisaurus (talk) 15:16, 2 June 2019 (UTC)