# Text - How to extract email addresses that are formatted with angle brackets

If you need to extract email addresses that are formatted in the friendly format "Display Name <displayname@companydomain.com>", this post describes the formula to carry out this task.

From time to time, I see questions from app builders who receive input data with email addresses that are formatted in the following ‘friendly’ fashion:

`"Display Name <displayname@companydomain.com>"`
How can we extract just the email address part of this input (ie displayname@companydomain.com)? This post describes how to carry out this task.

## How to extract email addresses inside brackets

Let’s assume that a text input control called txtEmail contains our input value.

To extract just the email address, we can use this formula:

`With({input: txtEmail.Text },          Mid(input,Find("<",input)+1,Find(">",input)-Find("<",input)-1))`
As the screenshot beneath illustrates, this returns our desired result.

Note that whilst it’s possible to accomplish the same result using regex and the Match function, this approach is easier for an average person to interpret.

Additionally, we can also easily adapt this pattern to return content that’s enclosed within other placeholder characters.

## How does this formula work?

To explain how this works, the Mid function extracts a substring from an input string, starting at a specified position and with a specified length. The syntax looks like this:

`Mid(text, start_num, num_chars)`
To obtain start_num, we call the Find function to return the character position of the first occurrence of "<". We add 1 to this so that the output doesn't contain the "<" character.

We calculate num_chars by calling the Find function to return the character position of the first occurrence of ">". We subtract the character position of "<", and subtract an additional 1 so as not to include the ">" character in the output.

## Conclusion

In situations where we need to retrieve an email address that’s enclosed in angle brackets, we can use the formula that’s shown in this post to accomplish the task.
•   Categories:
• text