Template talk:Remove first word

Latest comment: 4 years ago by Wikisaurus in topic Sep - several symbols

Result string does not contain true spaces edit

Because 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)Reply

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"
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"
  • "{{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)Reply

Sep - several symbols edit

One 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)Reply