I wish to transform a querystring using a regular expression replace in C#.
I have a number of defined querystring parameters (i.e. A, B and C).
I wish to transform something like this
page.aspx?A=XXX&B=YYY&C=1
into:
page/XXX/YYYY/true
Note that the first two parameters values for A and B are simply concatenated, but the part I'm having trouble with is changing the C=1
to true
in the output.
Can this even be done? If the C=1
part isn't found, I don't want to output anything:
page.aspx?A=XXX&B=YYY
becomes:
page/XXX/YYY
I don't think the order of A and B in the source querystring are ever in a different order, but could something be written to cope if B came before A?
I've been trying all sorts. Crucially, I'd love to know if this can be done, because if not, I'll have to do it another way.