Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- class HtmlUrlReplacer
- {
- static void Main()
- {
- string input = "<p>Please visit <a target = \"_blank\" href = \" http://academy.telerik. com \" >our site< / a > to choose a training course. Also visit <a href=\"www.devbg.org\">our forum</a> to discuss the courses.</p>";
- string result = Regex.Replace(input, @"<a[\s][^>]*\bhref\b[\s]*=[\s]*(""|')[\s]*(([^""'])+?)[\s]*\1[\s]*[^>]*[\s]*>([^<]*)<[\s]*/[\s]*a[\s]*>", "[URL=$2]$4[/URL]");
- Console.WriteLine(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement