Advertisement
Guest User

Untitled

a guest
May 16th, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Problem2_ReplaceATag
  9. {
  10. class ReplaceATag
  11. {
  12. static void Main()
  13. {
  14. string text = Console.ReadLine();
  15. string pattern = @"(<a\s+href=(?<link>[a-z]{4}:\/+[a-z]+[.][a-z]{1,3})>(?<text>[a-zA-z]+)<\/a>)";
  16. Match match = Regex.Match(text,pattern);
  17. string replace = "[URL href=" + match.Groups["link"] + "]" + match.Groups["text"] + "[/URL]";
  18. string result = Regex.Replace(text, pattern, replace);
  19. Console.WriteLine(result);
  20.  
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement