Hello, @terry-r and All,
I said :
I was waiting the Terry’s reply, first,…
Because I think it is more fair to let the first guy, helping the OP, to develop his solution ;-)) Then, you can jump into the discussion, proposing alternate solutions, too !
Besides, I know that I’m really too eager to give my regex solutions and, very often, I must prevent some people from helping their own solutions ;-))
Now, regarding your solution, you’re right about it : best to avoid large amounts of data inside the look-ahead structure ;-))
So, from the short example data, given in my previous post :
one
two
three
four
five
six
seven
eight
nine
ten
twenty-two
%%%%%%%%%%
twenty-two
five
nineteen
seven
First, using the Edit > Column Editor... option, at column 12 or more, we would get :
one 01
two 02
three 03
four 04
five 05
six 06
seven 07
eight 08
nine 09
ten 10
twenty-two 11
%%%%%%%%%% 12
twenty-two 13
five 14
nineteen 15
seven 16
And , after the Edit > Line Operations > Sort Lines Lexicographically Ascending option, we have :
%%%%%%%%%% 12
eight 08
five 05
five 14
four 04
nine 09
nineteen 15
one 01
seven 07
seven 16
six 06
ten 10
three 03
twenty-two 11
twenty-two 13
two 02
Now, using the following regex S/R :
SEARCH (?-s)^(.+)\x20+\d+\R\1\x20+\d+\R? OR (?-s)^(.+)(\x20+\d+\R?)\1(?2)
REPLACE Leave EMPTY
We are left with :
%%%%%%%%%% 12
eight 08
four 04
nine 09
nineteen 15
one 01
six 06
ten 10
three 03
two 02
Then, moving back the numbers from the end to the beginning of line and adding a space column, with the column mode selection, we would obtain :
12 %%%%%%%%%%
08 eight
04 four
09 nine
15 nineteen
01 one
06 six
10 ten
03 three
02 two
And, after a last ascending sort, we have :
01 one
02 two
03 three
04 four
06 six
08 eight
09 nine
10 ten
12 %%%%%%%%%%
15 nineteen
Finally, after processing this last regex S/R, we get our expected text, removing leading numbers and trailing spaces as well as anything from the separation line till the very end of file :
SEARCH (?s)^\d+\h*%%%+.+|^\d+\h*|\h+$
REPLACE Leave EMPTY
one
two
three
four
six
eight
nine
ten
Cheers,
guy038