I have the following string:
[Element][TOPINCLUDESAMEVALUES:5][ParentElement][ORDERBY:DateAdded]
and want to transform it to this:
[Element][TOP:5:WITHTIES][ParentElement][ORDERBY:DateAdded]
So, the [TOPINCLUDESAMEVALUES:5] is transform to [TOP:5:WITHTIES].
The input string could contain more [elements]. Each element is surrounded by square brackets []. For example:
...[element1][element2][TOPINCLUDESAMEVALUES:5]...[element3][element4][TOPINCLUDESAMEVALUES:105][element3]...
So, I need to transform each [TOPINCLUDESAMEVALUES:X] element to [TOP:X:WITHTIES] elements.
Generally, I try some combinations using regex replace substitutions but was not able to do it myself.
string statement = "[Campaign][TOPINCLUDESAMEVALUES:5][InstanceID][GROUPBY:Campaign]";
statement = Regex.Replace(statement, @"(?<=\[TOPINCLUDESAMEVALUES:)[^\]]+(?=\])", "");
Could anyone tell is there a way to do such replace?