Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- class ReplaceHTML
- {
- static void Main()
- {
- string text = @"<p>Please visit <a 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>";
- foreach (Match match in Regex.Matches(text, "<a href=\"(.*?)\">(.*?)</a>"))
- {
- string link = match.Groups[1].Value;
- string word = match.Groups[2].Value;
- text = Regex.Replace(text, "<a href=\"" + link + "\">" + word + "</a>", "[URL=" + link + "]" + word + "[/URL]");
- }
- Console.WriteLine(text);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement