title: ColdFusion: Strip Image Tag Attributes from an Image Tag
body: <p>I'm using the YUI Rich Text Editor to format a textarea within a CMS I'm building.  The CMS allows the user to upload and include images (its a blogging application). </p>
  
  <p>Just prior to writing the contents of the textarea to the database, I would like ColdFusion to do locate all the image tags, and to strip out any of the extraneous attributes beyond just the SRC. </p>
  
  <p>For example: </p>
  
  <pre><code>&lt;IMG src="foo.jpg" title="Foo!" alt="Foo!" height="100" width="100" style="border=1;"&gt;
  </code></pre>
  
  <p>Should come out the other end as: </p>
  
  <pre><code>&lt;IMG src="joo.jpg"&gt;
  </code></pre>
  
  <p>The challenge: </p>
  
  <ol>
  <li>Image attributes could be any, all or none of those listed in the example. </li>
  <li>The image attributes could be in any order</li>
  <li>The image tag could be located anywhere in the body of text from the textarea</li>
  </ol>
  
  <p>This ColdFusion exercise could be obviated if there were a way to tell YUI not to allow any image attributes, but I'm not sure if that's (easily) possible. </p>
  
  <p>Many kind thanks in advance!</p>
  
  <p>Best regards, </p>
  
  <p>Kris</p>