Deleting numbers from the Clipboard

I still have not understood the logic behind using the regular expression search and replace. Would someone please assist me here:
The clipboards are:
Per Idar Mullhaug 92645905
How to make KM output as final output (without the «»)

«Per Idar Mullhaug» (no space after the last character)

Per Idar Mullhaug

There might also be:
Ola Nordmann 22331122
How to make KM output as final output (without the «»)

«Ola Nordmann» (no space after the last character)

Ola Nordmann

Same procedure for both?

(Names and numbers are fictive)……

1 Like

It is always best to provide real-world data for both your source data (before) and the results you want (after); putting both in Code Blocks.

So, assuming something like:

«Per Idar Mullhaug» 92645905
«Ola Nordmann» 22331122

It is very easy to just remove the « and » characters using a Search and Replace action.
The RegEx is:
This uses the square brackets to indicate ANY of the characters within the brackets.

Example Output


MACRO:   Remove Unwanted Character from Source Using RegEx [Example]

~~~ VER: 1.0    2019-04-06 ~~~


Remove Unwanted Character from Source Using RegEx [Example].kmmacros (2.5 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


Does that answer your question?

1 Like

I think (based on the topic title) what he/she was asking was how to delete the numbers and just leave the name, and that the angle brackets were there just to show that there should be no space after the name, but the brackets aren't part of the actual data or the desired output. Sort of the way you might tell someone in a macro to "Put your data here" , but don't leave the quote marks in.

With that, back over to you, the regex pro.

1 Like

Yes you are right!

Thanks but I only want to output:

Ola Nordmann

Per Idar Mullhaug

(from the two samples)

In that case it is simple enough to INSERT another Replace Action:



The \h+ will remove ALL whitespace characters before the number.

1 Like

Yes it workded except for a "line change" or other system info (not sure what to call it). When I paste the result it looks great, but then seems to hit "enter" by itself (so the cursors enter the line below).
How to remove that?

This is exactly why I always ask for:

Let's jump to the final solution. Please post the above as requested.

Sorry not sure what you mean.
Anyway this is a screen dump of the result:
As you see the cursor did jump down......

You solved it! After trying one more time it seems to work fine just as I wanted! :slight_smile:

1 Like