 # How to get the top level domain (tld) from URL in Excel In this article, we will learn How to get the top level domain(tld) from URL in Excel.

Scenario :

First we want to understand what a top level domain is. If given any URL or email address, sometimes we need to extract the last part after . (char) of the given url or email. That last part is called top level domain. In the snapshot shown below a general type of url is given and the top level domain of the url is com. The http part is called protocol, then its subdomain, then domain and last is the top level domain separated by . (char). Below you will find more explanation about how to get a top level domain from any url or email address.

How to solve the problem?

Generally, the top level domain is found after the last . (char). For this problem, we will be using the following function.

Here we are going to use some logic to find the last .(char). RIGHT function extracts the text from the last knowing the number of characters to pick from last. That can be known if we differentiate the last . (char) from the rest . (char). The differentiating character must be a unique character. Then we will find the position of the differentiating character to get the start position of the top level domain.

Generic formula:

 =RIGHT (url, LEN(url) - FIND("%", SUBSTITUTE (url,".","%", LEN(url) - LEN ( SUBSTITUTE(url,".","")))))

url : given url or email address

% : differentiating character

. : lookup char

Example :

All of this might be confusing to understand. Let's understand this example via running it on an example. Here we have some urls and we need to extract to last value which will be the top level domain. Below is the formula to get the

Use the formula :

 =RIGHT (C4, LEN(C4) - FIND("%", SUBSTITUTE (C4, "." , "%" , LEN(C4) - LEN ( SUBSTITUTE(C4,".","")))))

Explanation:

• LEN ( SUBSTITUTE(C4, "." , "") returns the length of text in C4 without . (char).
• LEN(C4) returns the length of the string.
• The difference between the two will return the number of . (Char) in the text. Here we have 2 . (char), the formula drops down to.

= RIGHT( C4, 21 - FIND( "%" , SUBSTITUTE ( C4 , "." , "%" , 21-19 ) ) )

• SUBSTITUTE function replaces the . (char) with "%" (differentiating character) only at the 2nd occurrence. The formula drops down to.

• FIND function now finds the "%" (char) in string and returns its position.
• RIGHT function receives the num_char to return which is 3 from the right of the string. Here all the arguments to the formula given using the cell reference. Press Enter to get the result. As you can see in the above snapshot, the top level domain for the "http://www.google.com" is com. Now Copy the formula to the rest of cells using the shortcut Ctrl + D or dragging down the right bottom corner of the B2 cell. Here we can see that all the url or email address given to us, the formula extracts top level domain from all the values. Generally, we also receive the path value with url to get the

Here are all the observational notes regarding using the formula.

Notes:

1. The formula only works with numbers.
2. The differentiating character must be a unique character or else the formula returns error.
3. Check the parts of the formula, first select the part and use F9. This is used to do if you want to check how your formula is working and clearing out some mistakes.

Hope this article about How to get the top level domain (tld)  from URL in Excel is explanatory. Find more articles on text formulas here. If you liked our blogs, share it with your fristarts on Facebook. And also you can follow us on Twitter and Facebook. We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at info@exceltip.com

Related Articles:

Excel REPLACE vs SUBSTITUTE function : The REPLACE and SUBSTITUTE functions are the most misunderstood functions. To find and replace a given text we use the SUBSTITUTE function. Where REPLACE is used to replace a number of characters in string.

Replace text from end of a string starting from variable position : To replace text from the end of the string, we use the REPLACE function. The REPLACE function use the position of text in the string to replace.

How to Check if a string contains one of many texts in Excel : To find check if a string contains any of multiple text, we use this formula. We use the SUM function to sum up all the matches and then perform a logic to check if the string contains any of the multiple strings.

Count Cells that contain specific text : A simple COUNTIF function will do the magic. To count the number of multiple cells that contain a given string we use the wildcard operator with the COUNTIF function.

Popular Articles:

50 Excel Shortcuts to Increase Your Productivity : Get faster at your task. These 50 shortcuts will make you work even faster on Excel.

How to use Excel VLOOKUP Function : This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets.

How to use the COUNTIF Function in Excel : Count values with conditions using this amazing function. You don't need to filter your data to count specific values. Countif function is essential to prepare your dashboard.

How to Use SUMIF Function in Excel : This is another dashboard essential function. This helps you sum up values on specific conditions.

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.