title: perl regular expression to replace non printable characters in the form of &#xx;
body: <p>The XML character set is limited to the following:</p>
  
  <pre><code>[\x09\x0A\x0D\x20-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]
  </code></pre>
  
  <p>Entities may not be used to represent characters outside this set either.</p>
  
  <p>I am parsing some XML data files from an external source using XML::DOM. Some of the XML files have non-printable characters encoded in the form of &amp;#xx; (eg. <code>&amp;#15;</code>) which is causing the parser to crash as these are invalid. I am trying to find an easy way to remove these invalid characters. I have tried </p>
  
  <pre><code>$xml =~ s/(&amp;#\c\c;)//g;
  </code></pre>
  
  <p>which doesn't seem to work. SO doesn't seem to have anything related and I have been searching online for a while with no success.</p>