Advertisement
Perseus

ChangeTheTagsInHTMLDocument

Aug 11th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. //Write a program that replaces in a HTML document given as string all the tags <a href="…">…</a>
  2. //with corresponding tags [URL=…]…/URL].
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Text;
  7.  
  8. class ChangeTheTagsInHTMLDocument
  9. {
  10. static void Main()
  11. {
  12.  
  13. string input = @"<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>";
  14. string resultText = input.Replace("<a href=\"", "[URL=").Replace("</a>","[/URL]").Replace("\">","]");
  15.  
  16. Console.WriteLine(input);
  17. Console.WriteLine("\nThe result after exchange :\n");
  18. Console.WriteLine(resultText);
  19.  
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement