Created
May 13, 2015 11:20
-
-
Save aanguelov/577d0ea81c049a64b765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
namespace ReplaceATag | |
{ | |
class ReplaceATag | |
{ | |
static void Main() | |
{ | |
string text = Console.ReadLine(); | |
string pattern = @"(?<tag><a href=(?<link>http:\/\/\w+.\w+)>(?<text>\w+)<\/a>)"; | |
Match match = Regex.Match(text,pattern); | |
string replace = "[URL href=" + match.Groups[2] + "]" + match.Groups[3] + "[/URL]"; | |
string result = Regex.Replace(text, pattern, replace); | |
string quotes = @""""; | |
result = Regex.Replace(result, quotes, ""); | |
Console.WriteLine(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment