Explanation
In this example, the goal is to extract the name from a list of email addresses. In the current version of Excel, the easiest way to do this is with the TEXTBEFORE function or the TEXTSPLIT function. In older versions of Excel, you can use a formula based on the LEFT and FIND functions. All three options are explained below.
TEXTBEFORE function
The TEXTBEFORE function returns the text that occurs before a given delimiter. The generic syntax for TEXTBEFORE supports many options:
=TEXTBEFORE(text,delimiter,[instance_num],[match_mode],[match_end],[if_not_found])
However, most of these arguments are optional. For this problem, we only need to provide the first two arguments, text and delimiter :
=TEXTBEFORE(text,delimiter)
Text is the text string to split, and delimiter is the location at which to split the string. Since all email addresses contain the “@” character separating the name from the domain, we can extract the name with a formula like this:
=TEXTBEFORE(C5,"@")
As the formula is copied down the column, it extracts the name from each of the emails as shown in the worksheet. For more details on TEXTBEFORE, see How to use the TEXTBEFORE function .
Note: You can use the TEXTAFTER function to extract the domain from the email.
TEXTSPLIT function
Another easy way to solve this problem is with the TEXTSPLIT function , which is designed to split a text string at a given delimiter and return all parts of the split string in a single step. To solve this problem with TEXTSPLIT, use a formula like this in cell D5:
=TEXTSPLIT(C5,"@")
As the formula is copied down, TEXTSPLIT will split the email at the @ character and return the name and the domain. These two values will spill into column D and column E as seen below:

The advantage of this approach is that you get both the email and the domain with a single formula. For more details on TEXTSPLIT, see How to use the TEXTSPLIT function .
Legacy Excel
In older versions of Excel that do not provide the TEXTBEFORE or TEXTSPLIT functions, you can use a formula based on the LEFT and FIND functions:
=LEFT(C5,FIND("@",C5)-1)
At the core, this formula extracts characters from the left with the LEFT function, using FIND to figure out how many characters to extract. C5 contains the email “john.doe123@abc.com”, so FIND returns 12, since the “@” occurs as the 12th character. We then subtract 1 to prevent the formula from extracting the “@” along with the name:
FIND("@",C5)-1 // returns 11
The result is 11, which is returned directly to the LEFT function as the num_chars argument:
=LEFT(C5,11) // returns "john.doe123"
The final result returned by LEFT is “john.doe123”. As the formula is copied down the column, it performs the same operation on each email address. Although this formula is more complicated than the TEXTBEFORE or TEXTSPLIT options above, it achieves the same result.
Explanation
In this example, we have a list of URLs. The goal is to get the portion of each URL that appears after the domain name. In the current version of Excel, the easiest way to do this is to use the TEXTAFTER function. In an older version of Excel, you can use a formula based on the MID, FIND, and LEN functions. Both approaches are explained below.
TEXTAFTER function
The TEXTAFTER function returns the text that occurs after a given delimiter. The generic syntax for TEXTAFTER supports quite a number of options:
=TEXTAFTER(text,delimiter,[instance_num],[match_mode],[match_end], [if_not_found])
However, most of the inputs are optional and for this problem, we only need to provide the first three arguments:
=TEXTAFTER(text,delimiter,instance_num)
In the worksheet shown, the formula in cell D5 is:
="/"&TEXTAFTER(B5,"/",3)
The TEXTAFTER function is configured with the following inputs:
- text - the URL in cell B5
- delimiter - a forward slash “/”
- instance_num - 3, for the third occurrence of “/”
With the text “https://exceljet.net/formulas" in cell B5, TEXTAFTER splits the string at the third “/” and returns “formulas”. Next, a forward slash “/” is prepended to the result from TEXTAFTER with concatenation to create a final result that begins with “/”. This last step is necessary because TEXTAFTER does not include the delimiter used to split the text, so it needs to be added back manually if desired.
Legacy Excel
TEXTAFTER is a new function in Excel. In an older version of Excel, you can solve this problem with a formula based on the MID, FIND, and LEN functions:
=MID(B5,FIND("/",B5,9),LEN(B5))
At the core, this formula is extracting characters with the MID function , and using the FIND function to figure out where to begin extracting. First, FIND locates the “/” character in the URL, starting at the 9th character:
FIND("/",B5,9)
This is the “clever” part of the formula. URLs begin with something called a “protocol” (i.e. “http://”, “https://”, “ftp://”, “sftp://”, etc.) By starting at the 9th character, the protocol is skipped, and the FIND function returns the location of the third instance of “/”, which is the first forward slash “/” after the protocol. With the text “https://exceljet.net/formulas" in cell B5, the third instance of “/” is the 21st character in the URL, so FIND returns the number 21 to the MID function as the start_num argument. At this point, we have:
=MID(B5,21,LEN(B5))
To provide a value for the num_chars argument, we use the LEN function , which returns a count of all the characters in B5. This is a “hack” to keep things simple. LEN will return 29 in this case, the total number of characters in the text “https://exceljet.net/formulas". This means there are only 20 characters remaining after the “//”. However, the MID function doesn’t care if the number of characters ( num_chars ) exceeds the remaining string length. MID will just keep extracting characters until the end of the string. In other words, using LEN to provide num_chars is an easy way to give MID a number that is always enough to get the job done. Dropping in the value returned by the LEN function, we now have a formula that looks like this:
=MID(B5,21,29) // returns "/formulas"
The MID function begins extracting at character 21 and extracts all of the remaining text. The final result is “/formulas”. Unlike the TEXTAFTER version of the formula above, there is no need to concatenate a “/” to the beginning, since the MID function includes the delimiter in the result.