GerganaTsirkova

ReplaceTag

Mar 25th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace _10.ReplaceATag
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string text = Console.ReadLine();
  11.             List<string> result = new List<string>();
  12.             while(text != "end")
  13.             {
  14.                 if(text.Contains("<a")&&(text.Contains(">")))
  15.                 {
  16.                     text = text.Replace("<a", "[URL");
  17.                     text = text.Replace(">", "]");
  18.                 }
  19.                 if (text.Contains("</a") && (text.Contains(">")))
  20.                 {
  21.                     text = text.Replace("</a", "[/URL");
  22.                     text = text.Replace(">", "]");
  23.                 }
  24.                 result.Add(text);
  25.                 text = Console.ReadLine();
  26.             }
  27.             foreach (var item in result)
  28.             {
  29.                 Console.WriteLine(item);
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment