Page 1 of 1

Replace every 4th line break

Posted: Tue Aug 19, 2014 7:19 pm
by steve1040
I have a file with over 1000 lines

Like this
CM.ID=1448 OR
CM.ID=1740 OR
CM.ID=1741 OR
CM.ID=1742 OR
CM.ID=1744 OR
CM.ID=2621 OR
CM.ID=2622 OR
CM.ID=2623 OR

etc

I would like the file to look like this
CM.ID=1448 OR CM.ID=1740 OR CM.ID=1741 OR CM.ID=1742 OR
CM.ID=1744 OR CM.ID=2621 OR CM.ID=2622 OR CM.ID=2623 OR

Posted: Tue Aug 19, 2014 10:15 pm
by ben_josephs
I think you mean you want to replace every line break except every fourth one with a space.
Find what: (.*)\n(.*)\n(.*)\n(.*)\n
Replace with: $1 $2 $3 $4\n

[X] Regular expression

Replace All

Posted: Thu Aug 21, 2014 3:37 pm
by steve1040
ben_josephs wrote:I think you mean you want to replace every line break except every fourth one with a space.
Find what: (.*)\n(.*)\n(.*)\n(.*)\n
Replace with: $1 $2 $3 $4\n

[X] Regular expression

Replace All
Ben I get an error
States Cannot match Regular Expression

Any idea what I might be doing wrong?

Posted: Thu Aug 21, 2014 4:24 pm
by ben_josephs
Has a spurious space been introduced at the end of the regex?