Militsa

10. Replace a tag

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