开发者

Retrieve domain from wildcard URI

开发者 https://www.devze.com 2023-02-01 10:43 出处:网络
I need a suggestion on how could I retrieve the domain from the following : *.yahoo.co.uk *.yahoo.com so, in both cases, my method mus开发者_StackOverflow中文版t return yahoo.co.uk and yahoo.com.

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

  • *.yahoo.co.uk

  • *.yahoo.com

so, in both cases, my method mus开发者_StackOverflow中文版t 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


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[]{'.','*'}));


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

精彩评论

暂无评论...
验证码 换一张
取 消