Hello everyone and welcome to my blog. In today’s blog I will discuss about a very simple requirement on how to extract email address from string in Power Automate.
Requirements like this usually are solved using regular expressions. Canvas apps have support for regular expressions. There are couple of functions in Power Apps like Match and MatchAll which support regular expressions.
For our example, we shall extract the email addresses from the below text.
This is a sample text to demonstrate how you can extract the following email user1@sample.com from text. You
also need to extract the following emails
- user2@sample.com
- user3@Sample.com
I have put this text in a text input control
Since there are multiple email addresses to extract from the text, I will use the MatchAll function for this purpose. Below is the formula to accomplish the same.
Concat(
MatchAll(
TextInput2.Text,
"[a-zA-Z0-9._-]+@([a-zA-Z0-9_-]+\.)+[a-zA-Z0-9_-]+"
),
ThisRecord.FullMatch & ","
)
I use the this regular expression [a-zA-Z0-9._-]+@([a-zA-Z0-9_-]+\.)+[a-zA-Z0-9_-]+ to extract the email addresses. The MatchAll function returns a table. And I am using the Concat function to display the results inside a label control.
Pretty easy isn’t it? You don’t need to waste your time playing around with nasty string manipulations. I have used the regular expression to extract email but you can literally use this to extract any information like phone number, zip codes etc.
Hope you liked the post. If this post has helped, you can buy me a coffee. Links on right side panel.
You will also like the below posts.
Debajit Dutta
Business Solutions MVP
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.