Stephen Hacket's Clean Money Script

I’m trying to create this (see bottom of the page) useful macro but its not working. What am I doing wrong?

What exactly do you want to substitute? And what exactly doesn’t work?

Any explanation or more information about expected results, any example of input data?

Hi @rtoker, welcome to the forum.

Right, so that is a link to the Ruby script here which you have put into an execute shell script action in your macro.

The script seems to be syntactically correct and I gather it is meant to store the clipboard in p and then perform a text substition. I can’t see that you have done anything obviously wrong, but then I don’t know exactly what text you are testing on or exactly what you expect to happen. We need more than “it’s not working”! For future reference, please note that this section of the KM Wiki for some tips on submitting questions. For now, yes, @nutilius has identified what is needed so give us some more details and I’m sure someone will be able to help.

Not sure what it’s not doing, but here’s a simple way to “clean money” on the clipboard, depending how it’s formatted. It handles formats like $123.45, $1,234.56

[^\d\.?]

I’m glad someone understands these money laundering terms! :wink:

2 Likes

The script should definitely be called “Money Launderer” instead of “Clean Money” :+1: :money_with_wings:

2 Likes

LOL. Thank you!

It takes out the symbols and commas from amounts (e.g., $1,234.56) so they are easier to use in Google Sheets and Excel (i.e,. 1234.56).

Sorry about that. When I say its not working, I mean that when I copy a figure (e.g., $1,234.56) and then fire the KB macro, it doesn’t paste the number without the $ and , (i.e., 1234.56), which is the desired result.

1 Like

I figured it out. Instead of “save results to a clipboard” it should be “paste results”

It should be “paste results” if the idea was to paste the results! :wink:

Otherwise, the result (which, from a test macro I put together just now, I saw was correct) would have been stored as the content of the system clipboard, ready for you to paste or to use in another way. KM offers a lot of flexibility, and results of actions can be used in different ways. That’s why, you see, it’s important to be clear about what is expected from actions or macros even if the intended result might seem to be obvious.

Well done on finding a solution.

Thanks. I will definitely be more specific in the future and will check the tips on submitting questions.

1 Like

I don’t know how familiar you are with KM yet, but I hope my reply helped to give some useful context. Have fun!

...along with spaces, tabs, the ASCII - and Unicode "minus sign" (the "u2212" at the end of the list).

I'm not sure why SH shelled-out to use Ruby for this -- a KM-native search'n'replace is probably quicker, easier to understand, and easier to maintain:

But @evanfuchs's method of "delete everything except numbers and points" is even easier!

Given that the real number-line has (even, alas in economics) as many values below zero as above, it might also be prudent, or sobering or something, to retain the minus sign ?

[^\d.-]

2 Likes

Haha that never occurred to me, but good point!

1 Like

Depends what you're doing. Given that it was being removed in the original that would seem to be a requirement, so it makes sense to continue that in our versions.

If you were doing a home budget, for example, you'd have "Income" and "Outgoing" sections where you would (generally) use positive numbers in each but finish with a SUM(income) - SUM(Outgoings).

1 Like

Happy New Year !

(with no downsides, or negative sums :slight_smile: )