Find the Value of a Text Field By Searching for a Specific Field Format

I always have the same text, but the request number is the one that changes and it's the one I need to copy.

The text looks like this:

Thank you for submitting your request:

Request Number: 1-899-522-633
Account Number: XXXXXXXXXX

Someone will get back to you shortly.

I need to copy the request number only : 1-899-522-633 which changes every time. Is there a way to search a word/code by its format & copy to a variable/Clipboard?

Thanks so much!

This simple example will do what you want:
Test Find a specific text searching by format.kmmacros (3.2 KB)

Click to see macro

Since you haven't provided much detailed information about where you get the text from and what exactly you wish to do with the result, this example provides the very minimum that you have to implement. In your actual circumstances, it may be much more complicated.

Good luck!

1 Like

OMG Thanks so much! That worked perfectly! Do you have any recommendation to learn more about this action: Search using regular expression? tutorials or anything like that?

I've looked at the Wiki but it really didn't explain much...

TYSM again!

Hey Yisbel! You wouldn't believe how much discussion goes on in the KM forum about regular expressions :grinning:

So instead of taking my word for it, get yourself a drink and do a search of the KM forum (not the wiki) for regex or regular expression and be prepared for a long read. You'll find lots to feast on including plenty of reasons for not using regular expressions!

In any case, if you have specific questions or need help with problematical macros, this forum is the best place to ask!

3 Likes

:smiling_face_with_three_hearts: TYSM again!!!! Will do!

1 Like

Here's a place to start:

How Did You Learn RegEx (Regular Expressions)?

Did you look at the bottom of the wiki page where all the references are?

Regular Expressions [Keyboard Maestro Wiki]

2 Likes