Hi, @thunderdog, @peterjones and All,
Peter, nice shot , too ! As a sort was necessary, I simply thought about a second regex S/R. But you’re right, we can perfectly use a composite regex to get all the job done ;-))
So, the road map is :
Perform the regex S/R, twice
Run the alphabetic ( Unicode ) ascending sort
Perform the same regex S/R, once again
Note that I also slightly shorten your search regex ! Here is the final solution :
Assuming the initial text of @PeterJones, normalized in two lines, which does end with either a dot, an exclamation mark or an question mark !
The day was very difficult today. I hope the next few days get better. Do you hope the same? I hope you hope the same as me!
Hello, world! This sentence is just ten teeny-tiny words long, silly goose! No?
SEARCH (?-s)^#+\t(.+)#$|\w+[^\w\r\n]*(?=.*\t)|\h*(.+?[.?!])(?!#)
REPLACE ?2\2\t\2#\r\n:?1\1:#
After two clicks on the Replace All button, we obtain :
###### The day was very difficult today.#
######## I hope the next few days get better.#
##### Do you hope the same?#
######## I hope you hope the same as me!#
## Hello, world!#
########### This sentence is just ten teeny-tiny words long, silly goose!#
# No?#
Now, we click on the Edit > Line Operations > Sort Lines Lexicographically Ascending option and get :
# No?#
## Hello, world!#
##### Do you hope the same?#
###### The day was very difficult today.#
######## I hope the next few days get better.#
######## I hope you hope the same as me!#
########### This sentence is just ten teeny-tiny words long, silly goose!#
Let’s go back to fhe Replace dialog , again and use the same S/R
SEARCH (?-s)^#+\t(.+)#$|\w+[^\w\r\n]*(?=.*\t)|\h*(.+?[.?!])(?!#)
REPLACE ?2\2\t\2#\r\n:?1\1:#
After one final click on the Replace All button, here is your expected text :
No?
Hello, world!
Do you hope the same?
The day was very difficult today.
I hope the next few days get better.
I hope you hope the same as me!
This sentence is just ten teeny-tiny words long, silly goose!
Wow… Awesome !
And if we want to get all that text in a single paragraph, just apply this last regex S/R !
SEARCH ^\R|(\R)
REPLACE ?1\x20
giving :
No? Hello, world! Do you hope the same? The day was very difficult today. I hope the next few days get better. I hope you hope the same as me! This sentence is just ten teeny-tiny words long, silly goose!
Best Regards,
guy038