// Collection of code snippets by Arne Vajhøj
// posted to eksperten.dk, usenet and other places (2002-now)
using System;
using System.Text.RegularExpressions;
namespace E
{
public class Program
{
public static string Strip1(string s)
{
return Regex.Replace(s, @"<(.|\n)*?>", string.Empty);
}
public static string Strip2(string s)
{
return Regex.Replace(s, "<[^>]*>", "");
}
public static string Strip3(string s)
{
return Regex.Replace(s, "<(?!br)[^>]*>", "", RegexOptions.IgnoreCase);
}
public static void Main(string[] args)
{
String s = "bla bla
foo
bar
";
Console.WriteLine(s);
Console.WriteLine(Strip1(s));
Console.WriteLine(Strip2(s));
Console.WriteLine(Strip3(s));
}
}
}