Go into “Find and Replace”, click on “More > >”, and click “Use wildcards”.
(But you already knew that, right?)
Set “Find what” to {1,9}([0123456789])
Note that the first character is a space, and the second character is {
.
Set “Replace with” to ^p\1
(Caret, lower-case “P”, backslash, “one”)
- The
{1,9}
matches a string of between one and nine spaces.
This allows multiple spaces in the input; e.g.,
1 The quick brown 2 fox jumps over 4 the lazy dog.
[0123456789]
, of course, matches a number (specifically, a digit).
You can probably use [0-9]
instead.
- The
(
…)
delimit a capture group.
We want to capture the digit and ignore the spaces.
^p
, of course, is a paragraph break
(the equivalent of typing Enter).
If you want a line break
(the equivalent of typing Shift+Enter),
use ^l
(lower case “L”).
\1
substitutes the first capture group.
So: find a number, and replace it and the preceding spaces
with itself preceded by a break.
In other words, replace spaces with break before a number.
1Your before and after texts are identical ... – DavidPostill – 2019-06-08T19:23:17.987
You need to format your text correctly. I suggest formatting as code. – AFH – 2019-06-08T19:33:39.913
Yeah, sorry I did format the text correctly, but when I add it to the comment box it is okay. When I hit OK, the formatting is not retained? Don't know how to format as code?? The formatting I need is to have all the numbers at the left side of the the text, i.e. a line break before each number. I have been searching for ways to achieve this, but nothing so far! – John Michael Wilkinson – 2019-06-08T20:15:06.137
Ok, I finally managed to format the text correctly to show what I'm asking! I think my question is ready for answering... – John Michael Wilkinson – 2019-06-08T23:20:01.297