I'm trying to manipulate a string and I want to remove some characters in it.
Example scenario:
abc-def-c?p=2&x=5&z=6
I want to replace all chars starting from p
and ending with the char after next &
or ?
with empty chars. Deleting them in a way.
Input: abc-def-c?p=2&x=5&z=6
Output: abc-def-c?x=5&z=6
I know I can achieve this with Substring
,IndexOf
and Replace
but sadly there is a problem that p,x,y parts may not be in this order all the time. I need something which would find just the part and replace it.
My regex skills are not that great so any help is appreciated.