Trying to extract a code out of an email

Bjorn, thanks for your help here: How to use Regex in Make?

I feel like I’m super close to unlocking this power, but I’m still missing something. Can you help?

I’m trying to extract a code out of an e-mail. The automatic e-mail is sent to my inbox and is as follows:

[irrelevant text] Your Security code for User Agent: [[variable, in literal square brackets]] is: [four-character code] [irrelevant text]

I want to extract the four-character code to use in other modules.

I assume text parser is my friend, but I’m not sure how to use it.

So far I have

Your Security code for User Agent: [.*] is: …

But how do I deal with the irrelevant text pre- and post- string, and how to I actually extract the four-character code that I want?

Hi @Lydia,

In future, please create a new thread for each question. This makes it easier for others with the same problem to search for the answer. Thank you for your cooperation!

To answer your question, you’ll need to match your code in the regex as well.

As your code is four characters/alphabets long, that’s (?<code>[a-z0-9]{4}).

Also, using [.*] is wrong, because anything in the square brackets is a literal character. So you’ll only be matching a single character that is either a . or * character, which wouldn’t exist. You’d likely want .*? instead.

To put it together with what you currently have,

Your Security code for User Agent: .*? is: (?<code>[a-z0-9]{4})
2 Likes

Awesome. Thank you!! It worked!!

2 Likes