我怎样才能获取
"oauth_verifier=RN9vtxDFfozW51CSTuls0J4C&oauth_token=4%2F3uYq_3vYUSjXaFXtS74B_laW2V4d"
RN9vtxDFfozW51CSTuls0J4C
and
4%2F3uYq_3vYUSjXaFXtS74B_laW2V4d
从上面的字符串?
1)使用正则表达式
2)使用ToDictionary(选择器)
Regex:
使用积极的环视:
用于获取的正则表达式模式oauth_verifier
的值:
(?<=oauth_verifier=).+(?=&)
用于获取的正则表达式模式oauth_token
的值:
(?<=oauth_token=).+
e.g.:
string input = "oauth_verifier=RN9vtxDFfozW51CSTuls0J4C&oauth_token=4%2F3uYq_3vYUSjXaFXtS74B_laW2V4d";
string oauth_verifier = Regex.Match(input, "(?<=oauth_verifier=).+(?=&)").Value;
string oauth_token = Regex.Match(input, "(?<=oauth_token=).+").Value;
到字典
var dic = input.Split('&').ToDictionary( s => s.Remove(s.IndexOf('=')), s => s.Substring(s.IndexOf('=') + 1));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)