Remove email element from copied address

Hi
I'm trying to remove the email element from:
Person Smith personsmith@hotmail.com
I just want to paste "Person Smith"
Using the regex code [1]* which seems to work when I test it here: https://regex101.com.
When I use it in a keyboardmaestro function "Search and Replace System Clipboard Using Regular Expression (ignoring case)" it isolates the part I don't want rather than removing it. What am I doing wrong?


  1. ^< ↩︎

Sorry, my post was auto-formatted. Here's the text I'm working from

 Person Smith <personsmith@hotmail.com>

This is the regex I'm using

^[^<]*

I didn't quite follow the logic of the regex (my fault, and I shall look into that further), so for my reply I am using my own attempt at the regex: ^(.*)<.*

That's the start of the line ^, then the text we want to keep (indicated by putting it inside round brackets), followed by the angle bracket and zero or more following characters.

The $1 means the text that matches inside the (first and only) set of round brackets.

Just in case you didn't know: if you wanted to use a variable instead of just the clipboard, you could also use the search using regular expression action:

I have a feeling that I may be overlooking something but you might be able to get rid of the ^.

That's fab thanks very much. I now have it working :slight_smile:

1 Like

You don't need a regex -- you can use KM's pseudo array feature to get everything before the <:

image

3 Likes