title: Automatically hyper-link URL's and Email's using C#, whilst leaving bespoke tags in place
body: <p>I have a site that enables users to post messages to a forum.</p>
  
  <p>At present, if a user types a web address or email address and posts it, it's treated the same as any other piece of text.</p>
  
  <p>There are tools that enable the user to supply hyper-linked web and email addresses (via some bespoke tags/markup) - these are sometimes used, but not always. In addition, a bespoke 'Image' tag can also be used to reference images that are hosted on the web.</p>
  
  <p>My objective is to both cater for those that use these existing tools to generate hyper-linked addresses, but to also cater for those that simply type a web or email address in, and to then automatically convert this to a hyper-linked address for them (as soon as they submit their post).</p>
  
  <p>I've found one or two regular expressions that convert a plain string web or email address, however, I obviously don't want to perform any manipulation on addresses that are already being handled via the sites bespoke tagging, and that's where I'm stuck - how to EXCLUDE any web or email addresses that are already catered for via the bespoke tagging - I wan't to leave them as is.</p>
  
  <p>Here are some examples of bespoke tagging for the variations that I need to be left alone:</p>
  
  <pre><code>[URL=www.msn.com]www.msn.com[/URL]
  
  [URL=http://www.msn.com]http://www.msn.com[/URL]
  
  [EMAIL=bob@smith.com]bob@smith.com[/EMAIL]
  
  [IMG]www.msn.com/images/test.jpg[/IMG]
  
  [IMG]http://www.msn.com/images/test.jpg[/IMG]
  </code></pre>
  
  <p>The following examples would however ideally need to be automatically converted into web &amp; email links respectively:</p>
  
  <pre><code>www.msn.com
  
  http://www.msn.com
  
  bob@smith.com
  </code></pre>
  
  <p>Ideally, the 'converted' links would just have the appropriate bespoke tags applied to them as per the initial examples earlier in this post, so rather than:</p>
  
  <pre><code>&lt;a href="..." etc.
  </code></pre>
  
  <p>they'd become:</p>
  
  <pre><code>[URL=http://www.. etc.)
  </code></pre>
  
  <p>Unfortunately, we have a LOT of historic data stored with this bespoke tagging throughout, so for now, we'd like to retain that rather than implementing an entirely new way of storing our users posts.</p>
  
  <p>Any help would be much appreciated.</p>
  
  <p>Thanks.</p>