Extracting of e-mail from block of text

IDewar
Tera Expert

Hi there,

 

I am very new to creating Flows and the like so I am sure this is super simple. 

 

I wondering how I would capture an e-mail from a block of text such as:

 

"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac diam sed turpis laoreet viverra id quis velit. Suspendisse auctor turpis ac ipsum test.user@service-now.org fermentum auctor. Quisque velit augue, aliquam tempor fringilla quis, ultricies quis ante. Sed ac euismod massa. Proin eget maximus leo. Aenean interdum est lorem, venenatis sollicitudin ligula."

 

I have been trying to search for the ability to do this but can't see anyone answering this.

 

Thank you for any help you can give. 

1 ACCEPTED SOLUTION

LJ86
Kilo Guru
Hi Iain,

You will need a bit of code to achieve this, for example this should work:

 

 

var text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac diam sed turpis laoreet viverra id quis velit. Suspendisse auctor turpis ac ipsum test.user@service-now.org fermentum auctor. Quisque velit augue, aliquam tempor fringilla quis, ultricies quis ante. Sed ac euismod massa. Proin eget maximus leo. Aenean interdum est lorem, venenatis sollicitudin ligula.";

var emails = text.match(/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);

return emails[0];​

 

 

This will extract the first email found in the text. You can enter this code in a relevant action in Flow Designer (e.g. Log) to test it.

 
Of course, you're not likely to use it this way - I imagine you will have another action to capture the text from a record, etc. earlier in the flow. Depending on this, the script would need to be slightly tweaked, for example if you had the text captured in a flow variable called 'text', the script would be: 

 

 

var emails = fd_data.flow_var.text.match(/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
return emails[0];

 

 

Hope this helps,

Lukasz

View solution in original post

3 REPLIES 3

LJ86
Kilo Guru
Hi Iain,

You will need a bit of code to achieve this, for example this should work:

 

 

var text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac diam sed turpis laoreet viverra id quis velit. Suspendisse auctor turpis ac ipsum test.user@service-now.org fermentum auctor. Quisque velit augue, aliquam tempor fringilla quis, ultricies quis ante. Sed ac euismod massa. Proin eget maximus leo. Aenean interdum est lorem, venenatis sollicitudin ligula.";

var emails = text.match(/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);

return emails[0];​

 

 

This will extract the first email found in the text. You can enter this code in a relevant action in Flow Designer (e.g. Log) to test it.

 
Of course, you're not likely to use it this way - I imagine you will have another action to capture the text from a record, etc. earlier in the flow. Depending on this, the script would need to be slightly tweaked, for example if you had the text captured in a flow variable called 'text', the script would be: 

 

 

var emails = fd_data.flow_var.text.match(/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
return emails[0];

 

 

Hope this helps,

Lukasz

Hi there Lukasz,

 

This information was exactly what I was looking for! 

 

Thank you so much for your help with this. ^^

 

Kind Regards,

 

Iain

That's great to hear and happy to help!

Lukasz