C# 在Windows Phone运行时8.1中获取url参数

C# 在Windows Phone运行时8.1中获取url参数,c#,windows-runtime,windows-phone,windows-store-apps,windows-phone-8.1,C#,Windows Runtime,Windows Phone,Windows Store Apps,Windows Phone 8.1,我有这样一个字符串(这是来自Facebook登录对话框的响应): msft-{ProductID}://authorize/?access_-token={user-access-token}&expires_-in={token的过期时间} 我需要得到access_token变量的值 这里已经回答了相同的问题:,但不幸的是,HttpUtility在WindowsPhone8.1运行时中不存在。是否有HttpUtility.ParseQueryString的替代方法?一种简单的方法是使用正则表达

我有这样一个字符串(这是来自Facebook登录对话框的响应):

msft-{ProductID}://authorize/?access_-token={user-access-token}&expires_-in={token的过期时间}

我需要得到access_token变量的值


这里已经回答了相同的问题:,但不幸的是,HttpUtility在WindowsPhone8.1运行时中不存在。是否有HttpUtility.ParseQueryString的替代方法?

一种简单的方法是使用正则表达式。这应该起作用:

        var regex = new System.Text.RegularExpressions.Regex("[?&]access_token(?:=(?<token>[^&]*))?");

        var match = regex.Match (responseString);

        if (match.Success)
        {
            Console.WriteLine (match.Groups["token"]);
        }
var regex=new System.Text.RegularExpressions.regex(“[?&]access_-token(?:=(?[^&]*))?”;
var match=正则表达式匹配(responseString);
如果(匹配成功)
{
Console.WriteLine(match.Groups[“token”]);
}
来自MSDN页面:


根据“&”符号的数量和位置,使用wwformurldecoder类将查询字符串拆分为名称-值对。每个名称-值对都由一个IWWFormUrlDecodeRentry对象表示。

太好了!这就是我要找的。