Hi, @silent-resident, @peterjones, @alan-kilborn, @dinkumoil, and All,
@peterjones :
Peter, your search regex [^\.]\K(?=\R\R\d+$) ( which could be written [^.]\K(?=\R\R\d+$) ) does not work as expected ! Why ?
Well, considering the first sub-title, in a Windows file, your regex first matches the zero-length gap, between letter t and the \r EOL character and it correctly adds the … symbol. OK !
Now, the regex engine location is between the two characters … and \r. At this location, is there a single char, different from a dot, which can be followed with two line-breaks. The answer is YES : it’s just the \r EOL char, which is followed with \n ( so the first \R ) and the \r\n couple ( So, the second \R ). Thus, it adds a ... symbol between the \r and the \n of the first line-break
This situation cannot occur, again, right after as, if it had chosen the \r char ( as [^.] ), then the remaining EOL characters were, only, the \n character, which cannot match the \R\R part of your regex ! So, the next match happens, wrongly, between the \r and \n EOL characters, at the end of the line on earth’s surface. and so on ... -((
Luckily, 3 solutions are possible to get the right behaviour :
The [^.\r\n]\K(?=\R\R\d+$) syntax to forces the character, before the EOL characters, to be different from EOL chars !
The [^.]$\K(?=\R\R\d+$) syntax. Adding the $ anchor forces the [^.] character to be located right before an end of line ( so, obviously, not between the two EOL characters \r and \n). It’s the solution adopted by @dinkumoil !
Finally, use the exact Windows EOL definition, with the [^.]\K(?=\r\n\r\n\d+$) syntax
Cheers,
guy038