Amc_rtty
Amc_rtty

Reputation: 3803

Retrieve domain from wildcard URI

I need a suggestion on how could I retrieve the domain from the following :

so, in both cases, my method must return yahoo.co.uk and yahoo.com.

Is there an easy way to do this, or I just have to struggle with strings and counting characters from the "." and stuff like that?

Thank you in advance.

Regards,

Andrei

Upvotes: 1

Views: 663

Answers (2)

Chandu
Chandu

Reputation: 82893

You can use TrimStart if you are lokking for stripping just the '.' and '*' characters:

String testString = "*.yahoo.co.uk";
Console.WriteLine(testString.TrimStart(new char[]{'.','*'}));

Upvotes: 1

fejesjoco
fejesjoco

Reputation: 11903

if (s.StartsWith("*.")) s = s.Substring(2)

Upvotes: 1

Related Questions