How to remove a period from the end of clipboard text

I have a macro that strips/reformats clipboard text in various ways. How can I remove a period from the very end of the clipboard text string (if there is one), while keeping any other periods within the clipboard text intact? Thanks!

No doubt there are many ways to do this. But you can do it with Keyboard Maestro Actions using exactly the logic you describe - get the last character of the text in the Clipboard and if it is a period, remove that last character from the text.

EXAMPLE Remove last period if exists.kmmacros (4.9 KB)

Click to Show Image of Macro

3 Likes

Or with a regular expression:

Remove final period.kmmacros (2.9 KB)

-rob.

2 Likes

Thank you both for your suggestions; I implemented the regex solution and it worked perfectly!

1 Like

Here is another easy way using Search and Replace Using String - last match.

Dedicated to @ComplexPoint before he chimes in.

:slight_smile:

2 Likes

:slight_smile:

and, of course, Keyboard Maestro also provides some fairly declarative options, like defining a string with the last N characters dropped:

so, for example, we might write something like:

Without any trailling dot.kmmacros (5.0 KB)

2 Likes