Is there a built-in function to get the "ghi" from www.abc.com/def/ghi in the BCL?
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
精彩评论