public static string RemoveHTML(string text)
{
text = text.Replace(" ", " ").Replace("<br>", "
").Replace("description", "").Replace("INFRA:CORE:", "")
.Replace("RESERVED", "")
.Replace(":", "")
.Replace(";", "")
.Replace("-0/3/0", "");
var oRegEx = new System.Text.RegularExpressions.Regex("<[^>]+>");
return oRegEx.Replace(text, string.Empty);
}
string TrimWordsFromString(string value, int numberOfWords, char separator, bool reverse)
{
int trimmedWords = 0;
int index = 0;
while(trimmedWords != numberOfWords)
{
if(value == string.Empty)
{
return string.Empty;
}
if(reverse)
{
index = value.Length - 1;
}
if(value[index] == separator)
{
trimmedWords++;
}
value = value.Remove(index, 1);
}
return value;
}
//The following example removes all characters from a string that are after 25th position in the string.
string founder = "Mahesh Chand is a founder of C# Corner";
// Remove all characters after first 25 chars
string first25 = founder.Remove(25);
Console.WriteLine(first25);
//************************************ ^_*
//The following example removes 12 characters from the 10th position in the string.
// Remove characters start at the 10th position, next 12 characters
String newStr = founder.Remove(10, 12);
Console.WriteLine(newStr);