Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ReplaceTags
- {
- using System;
- using System.Text.RegularExpressions;
- class Program
- {
- static void Main(string[] args)
- {
- var pattern = new Regex(
- @"<a\b(?:[^>])*? href=(""|')(?<url>.+?)\1(?:[^>])*?>(?<text>[\W\w]+?)<\/a>",
- RegexOptions.Multiline);
- string text = Console.ReadLine();
- string result = pattern.Replace(text, new MatchEvaluator(ReplacesAncors));
- Console.WriteLine(result);
- }
- static string ReplacesAncors(Match match)
- {
- return string.Format(
- "[{0}]({1})", match.Groups["text"].Value, match.Groups["url"]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment