是否有内置函数可以获取“ghi”?来自 BCL 中的 www.abc.com/def/ghi?
BCL 中是否有内置函数可以从 www.abc.com/def/ghi
获取 ghi
?我知道创建一个执行此操作的小方法非常容易,但我想知道是否已经有一些东西可以为我处理它。
如果它也能让我得到 def
和 abc
那将是一个额外的好处。
Is there a built-in function to get the ghi
from 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 url 传递给 Uri 类构造函数 并检查 Segments 属性。或者,如果您拥有的字符串可能无效,您可以首先尝试使用 TryCreate< 来解析它/a> 方法。
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.
对于.net,只需使用 String.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
for .net just use String.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