How to delete spaces and other characters from clipboard text?

I am copying text from a website and saving it as a variable. I would like to “scrub” the text free of commas, periods and spaces before converting the clipboard to a variable. How do I do that using KM8?

Various routes to that. One way would be:

Purge text.kmmacros (19.3 KB)

Hey Ray,

That's a job for search & replace with regular expressions.

In the first replace action I'm replacing all commas and periods with a space.

Then I'm replacing any leading or trailing spaces of the whole text block with nothing.

Then I'm replacing any horizontal whitespace with a single space.

This probably isn't quite what you want, so post a good before and after example of your use-case.


Scrub - Commas- Periods- and Spaces.kmmacros (6.5 KB)

1 Like

Wow, that was fast! Thanks for your excellent help. Now to implement it. I’ll let you know if I have more questions.

Complex Point, your Javascript did the trick. I was confused until I realize I needed to update the ‘rawText’ variable with my own variable. Thanks so much!

1 Like