Advertisement
StoyanGrigorov

Untitled

Feb 8th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 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. //07. Replace a tag
  8. namespace ReplaceATag
  9. {
  10.     class ReplaceATag
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string input = Console.ReadLine();
  15.  
  16.             while (input != "end")
  17.             {
  18.                 string pattern = @"<a.*?href.*?=(.*)>(.*?)<\/a>";
  19.                 string replace = @"[URL href=$1]$2[/URL]";
  20.                 string replaced = Regex.Replace(input, pattern, replace);
  21.  
  22.                 Console.WriteLine(replaced);
  23.                 input = Console.ReadLine();
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement