title: Matching a URL Encoded e-mail address in C#
body: <p>I did some searching and didn't quite figure out why my solution is not working. Basically I need to take a string (which is HTML code) parse it and look for mailto links (which I then want to replace as part of an obfuscation). Here is what I have thus far: </p>
  
  <pre><code>    string text = "&lt;p&gt;Some Person&lt;br /&gt; Person's Position&lt;br /&gt;p. 123-456-7890&lt;br /&gt; e. &lt;a  title=\"Email Some Person\" target=\"_blank\" href=\"mailto:someperson%40domain.com\"&gt;someperson@domain.com&lt;/a&gt;&lt;/p&gt;";
      text = Server.UrlDecode(text);
      string safeEmails = Regex.Replace(text, "(&lt;a href=\"mailto:)(.*?)(%40)(.*?)(\"&gt;)(.*?)(&lt;/a&gt;)", "&lt;a class=\"mailme\" href=\"$2*$4\"&gt;$6&lt;/a&gt;");
      Response.Write( Server.HtmlDecode(safeEmails));
  </code></pre>
  
  <p>The text is coming out of a WYSIWYG text editor (Telrik RadEditor for those familiar) and for all intents and purposes I don't have access to be able to control what is coming out of it.</p>
  
  <p>Basically I need to find and replace any:</p>
  
  <pre><code>&lt;a href="mailto:someone%40domain.com"&gt;someone@domain.com&lt;/a&gt;
  </code></pre>
  
  <p>With:</p>
  
  <pre><code>&lt;a class="mailme" href="someone@domain.com"&gt;someone@domain.com&lt;/a&gt;
  </code></pre>
  
  <hr>
  
  <p>Some background: I am attempting to create a mailto link that will avoid detection by harvesters. The problem is that I receive a string with the e-mail as a standard mailto link. I cannot control the incoming string, so the mailto will always be an unprotected mailto. My object is to find all of them, obfuscate them, then use JavaScript to "fix" the link so that human vistors can easily use the mailto links. I am open to new approaches as well as modifications to the above code. </p>