Skip to content

Instantly share code, notes, and snippets.

@Patronski
Last active June 5, 2016 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Patronski/cf180f34b3a65b0728aee349a1d88c44 to your computer and use it in GitHub Desktop.
Save Patronski/cf180f34b3a65b0728aee349a1d88c44 to your computer and use it in GitHub Desktop.
using System;
using System.Text.RegularExpressions;
using System.Text;
public class P4ReplaceTag
{
public static void Main()
{
string input = Console.ReadLine();
string pattern = @"<a(href=.*?)>(.*?)<\/a>";
StringBuilder sb = new StringBuilder();
while(input != "end")
{
sb.Append(input);
sb.Replace(" ", ""); // removing white spaces
sb.Replace("\t", ""); // removing white spaces
input = Console.ReadLine();
}
string fromSB = sb.ToString();
input = Regex.Replace(fromSB, pattern, m => "[URL " + m.Groups[1].Value + "]" + m.Groups[2].Value + "[/URL]");
Console.WriteLine(input);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment