使用Regexp在KeyValuePair中获取信息

| 帮我解析此消息:
text=&direction=re&orfo=rus&files_id=&message=48l16qL2&old_charset=utf-8&template_id=&HTMLMessage=1&draft_msg=&re_msg=&fwd_msg=&RealName=0&To=john+%3Cjohn11%40gmail.com%3E&CC=&BCC=&Subject=TestSubject&Body=%3Cp%3EHello+%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82+%D1%82%D0%B5%D0%BA%D1%81%D1%82%3Cbr%3E%3Cbr%3E%3C%2Fp%3E&secur
我想在KeyValuePair中获取信息: 核心价值 文字- 方向-重新 等等。 以及如何转换为:
Hello+%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82+%D1%82%D0%B5%D0%BA%D1%81%...
有西里尔字母的字符。 谢谢。     
已邀请:
如果要使用正则表达式,可以这样进行:
// I only added the first 3 keys, but the others are basically the same
Regex r = new Regex(@\"text=(?<text>.*)&direction=(?<direction>.*)&orfo=(?<orfo>.*)\");
Match m = r.Match(inputText);

if(m.Success)
{
    var text = m.Groups[\"text\"].Value; // result is \"\"
    var direction = m.Groups[\"direction\"].Value; // re
    var orfo = m.Groups[\"orfo\"].Value;
}
但是,BoltClock建议的方法要好得多:
System.Collections.Specialized.NameValueCollection collection = 
    System.Web.HttpUtility.ParseQueryString(inputString);
    
看起来您正在处理URI,与尝试找出详细的处理方法相比,使用适当的类更好。 http://msdn.microsoft.com/en-us/library/system.uri.aspx     

要回复问题请先登录注册