title: Remove CDATA from XML with regex in Windows CMD (powershell)
body: <p>I am working with some XML data and I am stacked trying to remove CDATA in XML.
  I tried many ways, and it seems the simplier is by replacing all patterns </p>
  
  <pre><code>hey &lt;![CDATA[mate - number 1]]&gt; what's up
  </code></pre>
  
  <p>by </p>
  
  <pre><code>hey mate - number 1 what's up
  </code></pre>
  
  <p>Regex, in order to get the whole expression is <code>(\&lt;\!\[CDATA\[)(.*)(\]\]\&gt;)</code>, so when using PERL (PCRE), I just need to replace by <code>\2</code>.</p>
  
  <p>By this, and taking advantage of Powershell, I am running in CMD:</p>
  
  <pre><code>powershell -Command "(gc Desktop\test_in.xml) -replace '(\&lt;\!\[CDATA\[)(.*)(\]\]\&gt;)', '\2' | Out-File Desktop\test_out.xml")
  </code></pre>
  
  <p>Although the result is everthing is replaced by string <code>\2</code>, instead of <code>mate - number 1</code> in the example.</p>
  
  <p>Instead of <code>\2</code>, I tried <code>(?&lt;=(\&lt;\!\[CDATA\[))(.*?)(?=(\]\]\&gt;))</code> since I am getting with this the inner part I am trying to keep, although the result is frustating, again literal replacing.</p>
  
  <p>Any guess?</p>
  
  <p>Thank you!</p>
  
  <p>PS. If anyone know how to avoid this replacing in R, it is usefull as well.</p>