如何使用System.Web.HttpUtility.UrlEncode转换字符串数组中的单词
本文关键字:数组 字符串 单词 转换 UrlEncode 何使用 System Web HttpUtility | 更新日期: 2023-09-27 17:56:49
如何使用System.Web.HttpUtility.UrlEncode将字符串数组中的单词转换为好吧,也删除它 -> "!!*!!"
var array= new string []
{"windows!!1!!","dual+sim!!3!!","32+gb!!2!!","Intel+i5!!2!!","red%2fblue"};
输出阵列
var Output-array= new string []
{"windows","dual sim","32 gb","Intel i5","red/blue"}
如何在 C# 中的单行代码中做到这一点
这是HttpUtility.UrlDecode
string[] array = new string[] { "windows!!1!!", "dual+sim!!3!!", "32+gb!!2!!", "Intel+i5!!2!!", "red%2fblue" };
string[] result = array.Select(x => System.Web.HttpUtility.UrlDecode(System.Text.RegularExpressions.Regex.Replace(x, @"!!.*!!", "")).Replace("+", " ")).ToArray();