How can i replace {number}) with \n{number})
Say i have something like this
1) test string testing new string. 2) that is also a new string no new line. 3) here also no new lines.
The output should be something like this
1) test string testing new string.
2) that is also a new string no new line.
3) here also no new lines.
How can i do that with a regex?
Matches any set of digits followed by a literal
), replaces with a newline followed by those digits followed by a).If you want there to actually be a blank line in between like in your example output, you’d actually want to insert two newlines (since you need a newline to end the line with text, and then another to add the blank line). Just make it
\n\ninstead of\nin the second argument if such is the case.Also note that this will add a newline at the beginning of the string if it starts with a numbered point, so you might want to trim the string afterwards if you don’t want the leading newline.