如何在 WP7 中拆分 URI?

编程入门 行业动态 更新时间:2024-10-22 18:26:15
本文介绍了如何在 WP7 中拆分 URI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

WebBrowser 控件中是否有访问查询参数的方法,还是我们必须手动拆分字符串?例如:

Is there a method for accesing Query parameters in the WebBrowser control or do we have to manually break apart the string? For example:

www.mysite?paramter=12345

我只需要访问参数的值.我知道在使用 xaml 页面时,我们有 QueryString 属性.是否有类似的处理网页的方法?

I simply need to access the value of parameter. I know when working with xaml pages we have the have the QueryString property. Is there something similar for working with web pages?

推荐答案

我不记得我从哪里得到的,可能是这样.

I can't remember where I got this, possibly SO.

public static class UriExtensions { private static readonly Regex QueryStringRegex = new Regex(@"[\?&](?<name>[^&=]+)=(?<value>[^&=]+)"); public static IEnumerable<KeyValuePair<string, string>> ParseQueryString(this Uri uri) { if (uri == null) throw new ArgumentException("uri"); var matches = QueryStringRegex.Matches(uri.OriginalString); for (var i = 0; i < matches.Count; i++) { var match = matches[i]; yield return new KeyValuePair<string, string>(match.Groups["name"].Value, match.Groups["value"].Value); } } }

更多推荐

如何在 WP7 中拆分 URI?

本文发布于:2023-11-27 03:14:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   URI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!