Developers Heaven Forum

Desktop Programming => .NET Programming => ASP.NET => Topic started by: admin on August 28, 2008, 09:27:47 AM

Title: C# Regular Expression to Removing Subdomains from a URL
Post by: admin on August 28, 2008, 09:27:47 AM
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:

Code: [Select]
Regex.Replace( mySiteUrl, ".*SiteName", "SiteName", RegexOptions.IgnoreCase );