I have a rather large text file that has a bunch of missing newlines, meaning that it's a mess. I need to break it up into appropriate lines.
The text looks something like this now:
12345 This is a chunk 23456 This is another chunk 34567 This is yet another chunk 45678 This is yet more chunk 56789 Yet another piece of text
I need a regex that will insert a newline (CR/LF pair) before each group of five digits, resulting in something like this:
12345 This is a chunk
23456 This is another chunk
34567 This is yet another chunk
45678 This is yet more chunk
56789 Yet another piece of text
It can insert one before the first group of digits or not; that I can deal with.
Any ideas? Thanks.
Very simple (but not as "flashy" as possible, since I'm too lazy to use lookaheads):
s/(\d{5})/\r\n\1/gs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With