Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Write a program that replaces in a HTML document given as string all the tags <a href="…">…</a> with corresponding tags [URL href=…]…[/URL]. Print the result on the console. */
- namespace _02.Replace_a_Tag
- {
- using System;
- using System.Text.RegularExpressions;
- class ReplaceTag
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- const string pattern = @"<a\s([^>]+)>([^<]+)<\/a>";
- const string replacement = "[URL $1]$2[/URL]";
- Console.WriteLine(Regex.Replace(input, pattern, replacement));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement