Have a string like A=B&C=D&E=F, how to remove C=D part and get the string like A=B&E=F?
Either just replace it away:
input.Replace("&C=D", "");
or use one of the solutions form your previous question, remove it from the data structure and join it back together.
Using my code:
var input = "A=B&C=D&E=F"; var output = input .Split(new string[] {"&"}, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Split('=', 2)) .ToDictionary(d => d[0], d => d[1]); output.Remove("C"); output.Select(kvp => kvp.Key + "=" + kvp.Value) .Aggregate("", (s, t) => s + t + "&").TrimRight("&");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With