Advertisement
ellapt

T14.15.AnchorToURL

Feb 3rd, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. class AnchorToUrl
  5. {
  6. static void Main()
  7. {
  8. Console.WriteLine("Replace all the tags <a href='…'>…</a> with [URL=…]…/URL]\n");
  9.  
  10. string hyperText = "<p>Please visit <a href=\"http://academy.telerik.com\">our site</a> to choose a training course. Also visit <a href=\"www.devbg.org\">our forum</a> to discuss the courses.</p>";
  11.  
  12. Console.WriteLine("Original text: {0}\n", hyperText);
  13. Console.WriteLine(Regex.Replace(hyperText, "<a href=\"(.*?)\">(.*?)</a>", "[URL=$1]$2[/URL]"));
  14.  
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement