Select hyperlink and a meeting number from the text on the clipboard


I am trying to figure out how to select two items from the text generated by the zoom application when scheduling a meeting. When one copies zoom meeting invitation to the clipboard in order to later paste it into an email to invite a person to join, it generates the text you can see below (some numbers changes every time).

I want to figure out how to only get the actual URL (in bold) and only a the meeting number (in bold) to paste it later into the email, as amount of information is confusing to many people I invite to these meetings.

bs is inviting you to a scheduled Zoom meeting.

Topic: Peds GI Zoom Meeting
Time: Mar 19, 2020 11:00 AM Central Time (US and Canada)

Join Zoom Meeting

Meeting ID: 820 321 970

One tap mobile
+13126266799,,820321970# US (Chicago)
+19292056099,,820321970# US (New York)

Dial by your location
+1 312 626 6799 US (Chicago)
+1 929 205 6099 US (New York)
+1 253 215 8782 US
+1 301 715 8592 US
+1 346 248 7799 US (Houston)
+1 651 372 8299 US
+1 669 900 6833 US (San Jose)
Meeting ID: 820 321 970
Find your local number:

Join by SIP

Join by H.323 (US West) (US East) (China) (India Mumbai) (India Hyderabad) (EMEA) (Australia) (Hong Kong) (Brazil) (Canada) (Japan)
Meeting ID: 820 321 970

Yup, I'm going to be doing the same thing.

The good news is that this is fairly easy using the Terminal command egrep which is like grep but it allows for regular expressions.

Assuming that the text has already been selected and "copied" to the clipboard, all you need is this:

Now, here's where I explain what that means and how it works.

Here's the full command for copy/paste purposes:

pbpaste | egrep '(^https://umn-private\.zoom\.us|1 651 )'

Let's break that down by pieces:

pbpaste or "pasteboard paste" means "take the information that is on the pasteboard (aka clipboard) and send it to another command.

In Keyboard Maestro I think you could do the same thing by changing the "With input from" dropdown to "System Clipboard" but I'm used to using pbpaste because it works in all shell scripts on a Mac, so I use that.

The | just says "take the thing on the left and send it the command on the right.

egrep is a command used to look at a bunch of text and filter it down to just what we are looking for (you might also see grep and fgrep which are closely related commands.)

egrep CAT

says "show me all of the lines that include CAT (those exact letters, in order, in uppercase but it could be HOUSECAT or it could be CATALOG or just plain CAT)

egrep '(BEAR|CAT)'

says "show me all of the lines that include either BEAR or CAT.

egrep -i '(BEAR|CAT)'

the -i flag says to show me BEAR or CAT regardless of 'case' so BEAR or beAR or CaT etc.

egrep -i '(^BEAR|CAT)'

says "show me any lines that start with BEAR" (the ^ means "the very start of the line)

so it would match:

bear with me

but NOT

I saw a bear!

Ok, so let's apply that to our situation here…

We don't want to look for BEAR but we want to look for a URL which is at the start of the line. So we want to look for:


Really, that's all you need to use, but if you want to be more specific, you can be. You could use https:// or, as I showed above:


(I put a \ before the periods because in egrep a . means any character and here I meant `literally a period or "full stop" if you prefer).

So we want to search for that URL and we want to match the number that starts with 1 651

So I put those things together, I put (parenthesis) around it and | in between them just like (BEAR|CAT)

If you want to see the "Topic" and "Time" lines, you would use this:

pbpaste | egrep '(^https://umn-private\.zoom.\us|1 651 |^Topic: |^Time: )'

I hope that helps. Let me know if you have questions.

p.s. - Keyboard Maestro can probably do this with its native regex features, but I already know how to do it this way. If someone wants to share how to do this "natively" in Keyboard Maestro, I will not be hurt or offended :slight_smile:


Thank you very much for not only helping with the solution, but also teaching me how it works, so I can change it / or use it in the future!

I was editing my question and did not realize that you've already posted a response. I found out that the phone number does not change, only the meeting number does. So I changed the shell command to:

pbpaste | egrep '(^|Meeting ID: )'

it works great, but since Meeting ID appears three times in the clipboard message, the output is:

Meeting ID: 338 941 648

Meeting ID: 338 941 648

Meeting ID: 338 941 648

Is there a way to limit output to just one line?

Also a quick question - how do I save the result into a variable and use it to populate a text?

Regex example <7E38 200320T015947>-pty-fs8
Regex example <7E38 200320T015947>.kmmacros (4.4 KB)


Screen Shot 2020-03-20 at 01.59.38-pty-fs8


The m flag in the first expression is needed because I’m using the ^ anchor. (Otherwise ^ would mean ‘beginning of string’ (instead of ‘beginning of line’)

If you like living on the edge, you can also do it with a single expression:

Regex example <7E38 200320T022032>

(?ms)(^https.*?$).*?Meeting ID:\h*(.*?)$

Just one of several possible solutions.

how do I save the result into a variable and use it to populate a text?

This is included in the proposed solutions.

See also KM Wiki, as always.

1 Like

I figured out how to do it with your help and answered my own questions.

Here is the result:

To use I click copy invitation in zoom, then click in the body of the email and use Shift-Command-Z to active the macro.

Thank you for your help, tjluoma and Tom!

Zoom from clipboard.kmmacros (19.9 KB)

Fine if this works.

If you allow me a general hint: If feasible, always try to work with the content “directly”, instead of using UI scripting (clicking buttons, pressing shortcuts). Clicking buttons and such is made for human interaction. When communicating with the computer via scripts (or macros) you don’t have to take the detour via human interface thingies. Scripts are there (and allow you) to communicate more directly with the computer.

1 Like

I completely agree with your sentiment.

But I am not sure whether you are suggesting that Regex solution is better than one using shell expression, or whether I should think about automating opening email and pasting the result of either of the solutions after I click copy meeting info in zoom.

I was completely unspecific :wink:

I just saw the various “click” and shortcuts in your reply, and my hint was addressed to that.

If you are going to use a RegEx solution, it is almost always better to implement it a s a KM action. (Unless it will be integral part of a more extensive shell script, or in conjunction with some awk scripts, etc.)

Makes sense.

Thank you!

You're welcome. That's the hope -- not just how to solve this problem, but how to solve similar problems in the future.

Yes. In fact there are 3 ways to handle that.

  1. To select the first (or "top") result you would use this:

     pbpaste | egrep '^Meeting ID: ' | head -1
  2. To select the last (or "bottom") result you would use this:

     pbpaste | egrep '^Meeting ID: ' | tail -1
  3. To sort all of the matching lines and show just one unique match you would use this:

     pbpaste | egrep '^Meeting ID: ' | sort -u

(The -u flag to sort tells it to limit its output to unique matches)

In this case, any one of the three is an equally good choice, so pick whichever one you like.

The "Execute Shell Script" action has a dropdown which includes "Save results to variable".

If you wanted to do that, my recommendation would be to use two Execute Shell Script actions. Use the first to egrep for the URL and the second to egrep for the Meeting ID.

:no_mouth: :heart_eyes:

Edit: Edited wrong (non appropriate) emoji.

1 Like