Following this question:
https://stackoverflow.com/a/24591578/1329812
I am trying to use balanced matching to replace all items within brackets but in the example the brackets are "{{" and "}}". Whereas my brackets would be "<![CDATA[" and "]]>".
I am having trouble modifying the [^{}] section of the regular expression in the accepted answer to the previous question to use my version of brackets instead. I have tried to modify [^{}] to (?!(<!\[CDATA\|\]\]>)).
I have simplified the problem to use 12 as the open bracket and 34 as the close bracket. The following returns "STST" as expected.
using System.Text.RegularExpressions;
Regex.Replace(
12T1212E343434STST12RING34',--input
'12(?!(12|34))*(((?<Open>12)(?!(12|34))*)+((?<Close-Open>34)(?!(12|34))*)+)*(?(Open)(?!))34',--pattern
''--replacement
);
However it does not work if i replace 12 with <!\[CDATA\[" and 34 with "\]\]>.
Finally, I would like to operate on the following CDATA Sample String:
"<![CDATA[t<![CDATA[e]]>]]>stst<![CDATA[ring]]>"
should return
"stst"
 
    