fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Collections.Specialized;
  4. class Program
  5. {
  6. static void Main() {
  7. var myRegex = new Regex(@"<a.*?</a>|(hotmail)");
  8. string s1 = @"replace this=> hotmail not that => <a href=""http://h...content-available-to-author-only...l.com"">hotmail</a>";
  9.  
  10. string replaced = myRegex.Replace(s1, delegate(Match m) {
  11. if (m.Groups[1].Value != "") return "<span something>hotmail</span>";
  12. else return m.Value;
  13. });
  14. Console.WriteLine("\n" + "*** Replacements ***");
  15. Console.WriteLine(replaced);
  16.  
  17.  
  18. Console.WriteLine("\nPress Any Key to Exit.");
  19. Console.ReadKey();
  20.  
  21. } // END Main
  22. } // END Program
Success #stdin #stdout 0.07s 34800KB
stdin
Standard input is empty
stdout
*** Replacements ***
replace this=> <span something>hotmail</span> not that => <a href="http://h...content-available-to-author-only...l.com">hotmail</a>

Press Any Key to Exit.