title: Regular expression from font to span (size and colour) and back (VB.NET)
body: <p>I am looking for a regular expression that can convert my font tags (only with size and colour attributes) into span tags with the relevant inline css.  This will be done in VB.NET if that helps at all.</p>
  
  <p>I also need a regular expression to go the other way as well.</p>
  
  <p>To elaborate below is an example of the conversion I am looking for:</p>
  
  <pre><code>&lt;font size="10"&gt;some text&lt;/font&gt;
  </code></pre>
  
  <p>To then become:</p>
  
  <pre><code>&lt;span style="font-size:10px;"&gt;some text&lt;/span&gt;
  </code></pre>
  
  <p>So converting the tag and putting a "px" at the end of whatever the font size is (I don't need to change/convert the font size, just stick px at the end).</p>
  
  <p>The regular expression needs to cope with a font tag that only has a size attribute, only a color attribute, or both:</p>
  
  <pre><code>&lt;font size="10"&gt;some text&lt;/font&gt;
  
  &lt;font color="#000000"&gt;some text&lt;/font&gt;
  
  &lt;font size="10" color="#000000"&gt;some text&lt;/font&gt;
  
  &lt;font color="#000000" size="10"&gt;some text&lt;/font&gt;
  </code></pre>
  
  <hr>
  
  <p>I also need another regular expression to do the opposite conversion.  So for example:</p>
  
  <pre><code>&lt;span style="font-size:10px;"&gt;some text&lt;/span&gt;
  </code></pre>
  
  <p>Will become:</p>
  
  <pre><code>&lt;font size="10"&gt;some text&lt;/font&gt;
  </code></pre>
  
  <p>As before converting the tag but this time removing the "px", I don't need to worry about changing the font size.</p>
  
  <p>Again this will also need to cope with the size styling, font styling, and a combination of both:</p>
  
  <pre><code>&lt;span style="font-size:10px;"&gt;some text&lt;/span&gt;
  
  &lt;span style="color:#000000;"&gt;some text&lt;/span&gt;
  
  &lt;span style="font-size:10px; color:#000000;"&gt;some text&lt;/span&gt;
  
  &lt;span style="color:#000000; font-size:10px;"&gt;some text&lt;/span&gt;
  </code></pre>
  
  <hr>
  
  <p>I am extracting basic HTML &amp; text from CDATA tags in an XML file and then displaying them on a web-page. The text also appears in a rich-text editor so it can be edited/translated, and then saved back into a new XML file. The XML is then going to be read by a flash file, hence the need to use old-fashioned HTML.</p>
  
  <p>The reason I want to convert this code is mainly for display purposes. In order to show the text sizes correctly and for it to work with my rich text editor they need to be converted to XHTML/inline CSS. The rich text editor will also generate XHTML/inline CSS that I need to convert 'back' to standard HTML before it is saved in the XML file.</p>
  
  <p>I don't know a lot about XSLT transformation but I'm not sure that is what I need for this, or it might be more than I need right now, but please correct me if I'm wrong (and point me in the direction of any helpful links you may have on it).</p>
  
  <p>I know the temptation will be to tell me a number of different ways to set up my code to do what I want but there are so many other permutations I haven't even mentioned which have forced me down this route, so literally all I want to do is convert a string containing standard HTML to XHTML/inline CSS, and then the same but the other way round.</p>