C# Regular Expression to Removing Subdomains from a URL

Started by admin, August 28, 2008, 03:27:47 AM

Previous topic - Next topic

admin

Hello all,
if you need regular expression to remove all the subdomains from a url to leave only the domain name. e.g.

http://rss.abc.def.sitename.com.edu.au

<after applying regex leave>

SiteName.com.edu.au

Then you can use the following:

Regex.Replace( mySiteUrl, ".*SiteName", "SiteName", RegexOptions.IgnoreCase );