Actually, I have a very complex problem, but I have narrowed it down here to the most essential part with some dummy-data.
Say I have the following text:
a
aa
aaa
aaaa
aaaa
aaaaa
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaaa
a
What I would like to do is, FOR EXAMPLE when a line of 4 a’s is followed by a line of 1 a. I’d like to add a line of 3 a’s after the line of 4, and add a line of 2 a’s after the line of 3. So the result would be this:
a
aa
aaa
aaaa
aaaa
aaaaa
aaaa
aaa
aa
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaaaa
aaaa
aaa
aa
a
I have tried the folowing regex in editpad pro:
find: \r?\n(a*)aa\r?\n\1\r?\n
repl: \n\1aa\n\1a\n\1\n
But this only works when the next line has exactly 2 a’s less than the previous one.. I know I could write a bunch of regular expressions like the one above, to work for difference of 2 a’s, 3 a’s, 4 a’s, 5 a’s and so on. But I’d like to have only one regex. I don’t mind if I would have to run that regex multiple times though..
Just found a solution myself. Seems like I was very close, just overdid it a bit with the line breaks in the beginning.
This works after i repeatedly klick ‘replace all’ in editpad pro. I would like to have a solution where i need to run the replace all only once, so if there’s any further thoughts, please let me know