Page MenuHomePhabricator

#replace does not allow using a space for the replacement string
Open, Needs TriagePublic

Description

The StringFunctions version of #replace, would replace <nowiki> </nowiki> (<nowiki/> also worked, but wasn't documented) with a single space (implementation), allowing using a space as the replacement string, or to have a space at the start or end of the replacement string. This feature is not present in the ParserFunctions version of #replace.
A space as the replacement string can still be accomplished using <nowiki/> <nowiki/> (but that does seem a bit weirder), and a space at the start or end can be accomplished using <nowiki/> replacement, which is okay. However for compatibility, and so ParserFunction's functionality actually matches up with its documentation (the StringFunctions documentation is still considered the canonical documentation for the StringFunctions portion of ParserFunctions), the feature should be re-implemented, or ParserFunctions should have its own StringFunctions documentation, which reflects its actual use.

Event Timeline

Weirdly enough, you can use spaces as the search string and it will replace them correctly.

{{#replace:Some String With Spaces| |_}}
{{#replace:Some_String_With_Underlines|_| }}

Results in

Some_String_With_Spaces
SomeStringWithUnderlines

Also, {{#explode: }} handles spaces correctly