RegEx question: how to search for white space repetitions (1 tab and 1 new line)

It's possible to do multiple capture groups in one action, provided the text follows the same format. You will need to provide the relevant sample text block for test.


The former NASA engineer @JMichaelTX used to say “Better is the enemy of good enough...”

Since nothing is perfect one can always spend time in pursuit of better.

Since I'm a perfectionist by trade I have to make sure I don't go excessively far down that particular rabbit hole.


1 Like

I think I'll follow Chris' (@ccstone) advice and leave the macro itself alone since it works quite well. BUT, I also want to learn some more so I've included the sample text block for you to take a look at.

 Your Conference Details
Customer Name:	DHS U.S. Citizenship and Immigration Services
Site Name:	Houston (ZHN)
Language:	Spanish
Reference ID:	11111111
Call Duration:	00:00:01
Name	Status	
Name changed for security	CustomerConnected

I changed the reference ID and customer's name for security reasons, but they are still in the same format as what the actual text would read.

I need to extract the following info:

DHS U.S. Citizenship and Immigration Services
This name can be just one word or several as you can see.

Houston (ZHN)
This name can also be just one word or several.

Obviously that's not the real number, but it is always an 8-digit string.

Name changed for security
This is usually two or three words depending on if it's the actual persons name, or the name of their office.

So just for curiosity sake at this point (because why screw up a perfectly good macro I managed to reduce from 20 actions to 4? :laughing:) would there be a way to parse this information with a single action, and set each set of data to a separate variable?

The page's format is the same every single time...well, 98% of the time. For the other 2% I have 4 separate macros that can extract just one single item in case one of those items is missing (sometimes the participant's name is missing for example).


This is the action based on your sample text:
Search pattern:

Name:\s(.*?)\sSite Name:\s(.*?)\sLanguage(?:.|\s)+ID:\s(\d{8})\sCall(?:.|\s)+Status\s+(.*)\sCustomerConnected


aka spending 10 hours to save 10 minutes. :grin:
Guilty! :raised_hand:



  • That 10 minutes is repeatedly saved over time.
  • Keeps me from pulling my hair out.
  • Improves the likelihood that I'll get work done on time.
  • Makes my work more accurate.


  • Helps me to learn things that will facilitate the above.
  • Is a FUN pastime that takes the place of other leisure activities, and let's me learn something at the same time.

I'll gladly spend the 10 hours.


  • If I'm not getting paid for the work.
    • I better take a good long look at why I'm doing what I'm doing.




I must have messed up the formatting when I posted it, because using the action you built doesn’t return me any results. I’ll take a closer look at it tomorrow though and see what I can figure out.

A good portion of my time spent building and tweaking macros is for these very reasons, either to learn and/or to just have fun haha.

1 Like

Hey Chris,

How are you acquiring the data in the first place?


Copy contents of page to system clipboard and then filtering to remove styles. But I have several copies saved in text files on my computer to test things with and I used one of those in a previous post. It must have gotten corrupted somehow; likely I deleted some white space character or the like.


In what browser?


Bring page to front, keystroke ⌘A, copy to clipboard, filter clipboard to remove styles to target source

Google Chrome.

Don't do that.

Run this in a Execute a JavaScript in Front Browser action:


Better yet – find the correct element(s) and get the correct text on the first try.


Thank you! I'll test this when I'm back at work on Monday.

The info I extract is only on screen when I'm on an active call, and many times while I'm on the call I'm not able to do must testing so some of these things take a long time to test and implement.

Also as you're well aware I've been working on learning my AppleScript and RegEx lately so I haven't delved into JavaScript at all...yet!

EDIT: Your simple reply made me think of another use case where this could come in VERY handy...and back down the rabbit hole I go :grin:

1 Like

Just some thoughts:

It's also possible that the invisible characters are filtered by the browsers during your posting or my browser's loading.
You may put it in a text action in KM and upload that to the forum.

If the original data has different numbers of invisible signs, it might be easier to use regex to filter those signs first before getting the targeted data.

1 Like

Use Google Chrome to save one or more examples in the following format for testing at your convenience:



...and the rabbit hole gets deeper. Thank you, I'll make sure to do this Monday. As always, you're the man.

Here's the clipboard contents from my last call today, which I haven't touched except to remove anything before and after the relevant data.

It has only been filtered to remove styles, so all the white space should be intact.

VP contents filtered.kmmacros (1.3 KB)

I copied the text from your macro and I can still get what I wanted. Maybe my regex search string was filtered by the browser?
This is mine:
RegEx.kmmacros (2.4 KB)

Welp....I figured it out...and I don't know how it happened but somehow there was a line break at the end of the RegEx string that was making it fail. It works spectacularly now :laughing:

Thanks for your help and for troubleshooting it the last couple days too!

1 Like