Tidy Clipboard Text to Remove Blank Lines inc Space and Tabs

Hello again. One of my team has this specific use case that I can't quite work out. It's hopefully the final script we need migrate from AutoHotkey.

Basically we want to take the contents of the Clipboard and clean it up.

Here is link to an example text file that can be used test this.

Example.TXT

As you can see from this screenshot of the above file, that there are some spaces, tabs etc in the file.

Now what should happen is this

All Multiple Blank lines should be removed. A blank line may have just a space , or a tab, or just a line break or carriage return character. A single blank line should not be modified.

So this clipboard text

Should end up looking like this.

Many thanks in advance for the help as always.

Hi @AndyPage ,
Does something like this works?

{text="Ep 1607: What Doesn’t Kill Us (Available to stream Thursday, January 19)

With the fate of the Sicarius investigation hanging in the balance, the BAU takes a case in West Virginia, where an UnSub practices his own twisted form of Old Testament vengeance.





Written by: Sullivan Fitzgerald
Directed by: Aisha Tyler



dd

d


Last Line
"}{=text}
#############
{=replaceregex(text, "(\n\s)\s{1,}", "$1", "sg")}

1 Like

Wow, that's works brilliantly. Thank you so much.

1 Like