开发者

Is there a built-in function to get the "ghi" from www.abc.com/def/ghi in the BCL?

开发者 https://www.devze.com 2023-03-30 01:37 出处:网络
Is there a built-in function to get the ghi f开发者_JAVA百科rom www.abc.com/def/ghi in the BCL? I know it is dead easy to create a small method that does just that, but I wonder if there is something

Is there a built-in function to get the ghi f开发者_JAVA百科rom www.abc.com/def/ghi in the BCL? I know it is dead easy to create a small method that does just that, but I wonder if there is something already that will take care of it for me.

If it could also get me def and abc that'd be a bonus.


You could pass the url to the Uri class constructor and inspect the Segments property. Or if the string you have could be invalid you could first try parsing it using the TryCreate method.


for .net just use String.Split

myString.Split('/')
and take the array-parts you need - I don't think that there is a build in function - it won't be much shorter than this anyway

0

精彩评论

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