Page MenuHomePhabricator

Search and replace a newline
Open, Needs TriagePublicFeature

Description

Hello!
Few days ago I received file with text that I wanted to upload. But the concept of the text wasn't suitable to the wikitext, and one of the problems is the multiple newline in the wikitext. I wanted to fix that by multiplying every newline, but it's impossible in the build-in search and replace feature.
Later, I thought about a solution, to use regex and replace '(\n)' with '$1$1'. But it's not working when you don't have already one newline, because the second box doesn't understand the '\n' if it's not in $, even if it's on the regex mode.
I think that '\n', or other term, must be possible term in the search and replace boxes, also in the simple mode (and of course in the regex).
Thanks.

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenFeatureNone

Event Timeline

Aklapper changed the subtype of this task from "Task" to "Feature Request".Apr 29 2021, 9:44 AM

A little workaround I thought of (instead of using an external editor) is to replace with a substitution of a template that outputs a newline. I don't know of such a template on any wiki (for example, Template:Break on enwiki evaluates to <br />), so I put <onlyinclude></onlyinclude> surrounding a newline on my user page and now use {{subst:user:wqnvlz}}.

With wikitext:

foo, bar, baz, qux

searching for and replacing with {{subst:user:wqnvlz}}*  then gives:

foo{{subst:user:wqnvlz}}* bar{{subst:user:wqnvlz}}* baz{{subst:user:wqnvlz}}* qux

which, when saved, becomes:

foo
* bar
* baz
* qux

Would it be sensible to create a whole template for wqnvlz's hack? I implemented the same and found minor issues, but it works. Is this an issue likely to be solved sooner... or later?